5 WARNING: THIS MODULE IS EXTREMELY DANGEROUS AS IT ENABLES INLINE SCRIPTING
6 INSIDE HTML PURIFIER DOCUMENTS. USE ONLY WITH TRUSTED USER INPUT!!!
11 * Implements required attribute stipulation for <script>
13 class HTMLPurifier_AttrTransform_ScriptRequired
extends HTMLPurifier_AttrTransform
15 function transform($attr, $config, &$context) {
16 if (!isset($attr['type'])) {
17 $attr['type'] = 'text/javascript';
24 * XHTML 1.1 Scripting module, defines elements that are used to contain
25 * information pertaining to executable scripts or the lack of support
26 * for executable scripts.
27 * @note This module does not contain inline scripting elements
29 class HTMLPurifier_HTMLModule_Scripting
extends HTMLPurifier_HTMLModule
31 var $name = 'Scripting';
32 var $elements = array('script', 'noscript');
33 var $content_sets = array('Block' => 'script | noscript', 'Inline' => 'script | noscript');
35 function HTMLPurifier_HTMLModule_Scripting() {
36 // TODO: create custom child-definition for noscript that
37 // auto-wraps stray #PCDATA in a similar manner to
38 // blockquote's custom definition (we would use it but
39 // blockquote's contents are optional while noscript's contents
42 // TODO: convert this to new syntax, main problem is getting
43 // both content sets working
44 foreach ($this->elements
as $element) {
45 $this->info
[$element] = new HTMLPurifier_ElementDef();
46 $this->info
[$element]->safe
= false;
48 $this->info
['noscript']->attr
= array( 0 => array('Common') );
49 $this->info
['noscript']->content_model
= 'Heading | List | Block';
50 $this->info
['noscript']->content_model_type
= 'required';
51 $this->info
['script']->attr
= array(
52 'defer' => new HTMLPurifier_AttrDef_Enum(array('defer')),
53 'src' => new HTMLPurifier_AttrDef_URI(true),
54 'type' => new HTMLPurifier_AttrDef_Enum(array('text/javascript'))
56 $this->info
['script']->content_model
= '#PCDATA';
57 $this->info
['script']->content_model_type
= 'optional';
58 $this->info
['script']->attr_transform_pre
['type'] =
59 $this->info
['script']->attr_transform_post
['type'] =
60 new HTMLPurifier_AttrTransform_ScriptRequired();