Fix problem where stacked AttrTransforms clobber each other.
[htmlpurifier.git] / library / HTMLPurifier / HTMLModule / Scripting.php
blob2ac0d8021d6fb9207458f59af8988b0ccb2e9d98
1 <?php
3 /*
5 WARNING: THIS MODULE IS EXTREMELY DANGEROUS AS IT ENABLES INLINE SCRIPTING
6 INSIDE HTML PURIFIER DOCUMENTS. USE ONLY WITH TRUSTED USER INPUT!!!
8 */
10 /**
11 * XHTML 1.1 Scripting module, defines elements that are used to contain
12 * information pertaining to executable scripts or the lack of support
13 * for executable scripts.
14 * @note This module does not contain inline scripting elements
16 class HTMLPurifier_HTMLModule_Scripting extends HTMLPurifier_HTMLModule
18 public $name = 'Scripting';
19 public $elements = array('script', 'noscript');
20 public $content_sets = array('Block' => 'script | noscript', 'Inline' => 'script | noscript');
21 public $safe = false;
23 public function setup($config) {
24 // TODO: create custom child-definition for noscript that
25 // auto-wraps stray #PCDATA in a similar manner to
26 // blockquote's custom definition (we would use it but
27 // blockquote's contents are optional while noscript's contents
28 // are required)
30 // TODO: convert this to new syntax, main problem is getting
31 // both content sets working
33 // In theory, this could be safe, but I don't see any reason to
34 // allow it.
35 $this->info['noscript'] = new HTMLPurifier_ElementDef();
36 $this->info['noscript']->attr = array( 0 => array('Common') );
37 $this->info['noscript']->content_model = 'Heading | List | Block';
38 $this->info['noscript']->content_model_type = 'required';
40 $this->info['script'] = new HTMLPurifier_ElementDef();
41 $this->info['script']->attr = array(
42 'defer' => new HTMLPurifier_AttrDef_Enum(array('defer')),
43 'src' => new HTMLPurifier_AttrDef_URI(true),
44 'type' => new HTMLPurifier_AttrDef_Enum(array('text/javascript'))
46 $this->info['script']->content_model = '#PCDATA';
47 $this->info['script']->content_model_type = 'optional';
48 $this->info['script']->attr_transform_pre[] =
49 $this->info['script']->attr_transform_post[] =
50 new HTMLPurifier_AttrTransform_ScriptRequired();
54 // vim: et sw=4 sts=4