3 class HTMLPurifier_AttrTransform_ParamValidator
extends HTMLPurifier_AttrTransform
5 var $name = "ParamValidator";
8 function HTMLPurifier_AttrTransform_ParamValidator() {
9 $this->uri
= new HTMLPurifier_AttrDef_URI();
12 function transform($attr, $config, $context) {
13 switch ($attr['name']) {
14 case 'allowscriptaccess':
15 $attr['value'] = 'never';
18 $attr['value'] = 'window';
21 $attr['value'] = 'false';
24 $attr['value'] = $this->uri
->validate($attr['movie'], $config, $context);
28 $attr['name'] = $attr['value'] = null;
34 class HTMLPurifier_AttrTransform_ObjectValidator
extends HTMLPurifier_AttrTransform
36 var $name = "ObjectValidator";
38 function transform($attr, $config, $context) {
39 if (!isset($attr['type'])) $attr['type'] = 'application/x-shockwave-flash';
44 $config->set('AutoFormat', 'Custom', array('AddParam'));
45 $config->set('HTML', 'DefinitionID', 'allow flash movies');
46 $config->set('HTML', 'DefinitionRev', 1);
47 $config->set('Cache', 'DefinitionImpl', null); //remove this later
48 $def =& $config->getHTMLDefinition(true);
50 $param =& $def->addElement(
52 false, //only appears in object tags, remove elsewhere
56 // this by default is insecure, and must have a validator
62 $param->attr_transform_post
[] = new HTMLPurifier_AttrTransform_ParamValidator();
64 $object =& $def->addElement(
67 'Optional: param | #PCDATA',
70 'type*' => 'Enum#application/x-shockwave-flash',
72 'height*' => 'Pixels',
76 $object->attr_transform_post
[] = new HTMLPurifier_AttrTransform_ObjectValidator();
80 $embed =& $def->addElement(
86 'type*' => 'Enum#application/x-shockwave-flash',
88 'height*' => 'Pixels',
90 'flashvars' => 'Text',
91 'allowscriptaccess' => 'Enum#never',
92 'enablejsurls' => 'Enum#false',
93 'enablehref' => 'Enum#false',
95 //these will all be ignored by the injector
97 'pluginspage' => 'URI',
98 'saveembedtags' => 'Text',
105 class HTMLPurifier_AttrTransform_EmbedValidator
extends HTMLPurifier_AttrTransform
107 var $name = "EmbedValidator";
109 function transform($attr, $config, $context) {
110 $attr['allowscriptaccess'] = 'never';
111 $attr['enablejsurls'] = 'false';
112 $attr['enablehref'] = 'false';
116 $embed->attr_transform_post
[] = new HTMLPurifier_AttrTransform_EmbedValidator();
118 class HTMLPurifier_Injector_AddParam
extends HTMLPurifier_Injector
120 var $name = 'AddParam';
121 var $needed = array('object', 'param');
122 function handleElement(&$token) {
123 if ($token->name
== 'object') {
126 new HTMLPurifier_Token_Start('param', array('name' => 'enablejsurls', 'value' => 'false'))