@@ -18,226 +18,226 @@ |
||
18 | 18 | class HTMLPurifier_HTMLModule |
19 | 19 | { |
20 | 20 | |
21 | - // -- Overloadable ---------------------------------------------------- |
|
22 | - |
|
23 | - /** |
|
24 | - * Short unique string identifier of the module |
|
25 | - */ |
|
26 | - public $name; |
|
27 | - |
|
28 | - /** |
|
29 | - * Informally, a list of elements this module changes. Not used in |
|
30 | - * any significant way. |
|
31 | - */ |
|
32 | - public $elements = array(); |
|
33 | - |
|
34 | - /** |
|
35 | - * Associative array of element names to element definitions. |
|
36 | - * Some definitions may be incomplete, to be merged in later |
|
37 | - * with the full definition. |
|
38 | - */ |
|
39 | - public $info = array(); |
|
40 | - |
|
41 | - /** |
|
42 | - * Associative array of content set names to content set additions. |
|
43 | - * This is commonly used to, say, add an A element to the Inline |
|
44 | - * content set. This corresponds to an internal variable $content_sets |
|
45 | - * and NOT info_content_sets member variable of HTMLDefinition. |
|
46 | - */ |
|
47 | - public $content_sets = array(); |
|
48 | - |
|
49 | - /** |
|
50 | - * Associative array of attribute collection names to attribute |
|
51 | - * collection additions. More rarely used for adding attributes to |
|
52 | - * the global collections. Example is the StyleAttribute module adding |
|
53 | - * the style attribute to the Core. Corresponds to HTMLDefinition's |
|
54 | - * attr_collections->info, since the object's data is only info, |
|
55 | - * with extra behavior associated with it. |
|
56 | - */ |
|
57 | - public $attr_collections = array(); |
|
58 | - |
|
59 | - /** |
|
60 | - * Associative array of deprecated tag name to HTMLPurifier_TagTransform |
|
61 | - */ |
|
62 | - public $info_tag_transform = array(); |
|
63 | - |
|
64 | - /** |
|
65 | - * List of HTMLPurifier_AttrTransform to be performed before validation. |
|
66 | - */ |
|
67 | - public $info_attr_transform_pre = array(); |
|
68 | - |
|
69 | - /** |
|
70 | - * List of HTMLPurifier_AttrTransform to be performed after validation. |
|
71 | - */ |
|
72 | - public $info_attr_transform_post = array(); |
|
73 | - |
|
74 | - /** |
|
75 | - * List of HTMLPurifier_Injector to be performed during well-formedness fixing. |
|
76 | - * An injector will only be invoked if all of it's pre-requisites are met; |
|
77 | - * if an injector fails setup, there will be no error; it will simply be |
|
78 | - * silently disabled. |
|
79 | - */ |
|
80 | - public $info_injector = array(); |
|
81 | - |
|
82 | - /** |
|
83 | - * Boolean flag that indicates whether or not getChildDef is implemented. |
|
84 | - * For optimization reasons: may save a call to a function. Be sure |
|
85 | - * to set it if you do implement getChildDef(), otherwise it will have |
|
86 | - * no effect! |
|
87 | - */ |
|
88 | - public $defines_child_def = false; |
|
89 | - |
|
90 | - /** |
|
91 | - * Boolean flag whether or not this module is safe. If it is not safe, all |
|
92 | - * of its members are unsafe. Modules are safe by default (this might be |
|
93 | - * slightly dangerous, but it doesn't make much sense to force HTML Purifier, |
|
94 | - * which is based off of safe HTML, to explicitly say, "This is safe," even |
|
95 | - * though there are modules which are "unsafe") |
|
96 | - * |
|
97 | - * @note Previously, safety could be applied at an element level granularity. |
|
98 | - * We've removed this ability, so in order to add "unsafe" elements |
|
99 | - * or attributes, a dedicated module with this property set to false |
|
100 | - * must be used. |
|
101 | - */ |
|
102 | - public $safe = true; |
|
103 | - |
|
104 | - /** |
|
105 | - * Retrieves a proper HTMLPurifier_ChildDef subclass based on |
|
106 | - * content_model and content_model_type member variables of |
|
107 | - * the HTMLPurifier_ElementDef class. There is a similar function |
|
108 | - * in HTMLPurifier_HTMLDefinition. |
|
109 | - * @param $def HTMLPurifier_ElementDef instance |
|
110 | - * @return HTMLPurifier_ChildDef subclass |
|
111 | - */ |
|
112 | - public function getChildDef($def) {return false;} |
|
113 | - |
|
114 | - // -- Convenience ----------------------------------------------------- |
|
115 | - |
|
116 | - /** |
|
117 | - * Convenience function that sets up a new element |
|
118 | - * @param $element Name of element to add |
|
119 | - * @param $type What content set should element be registered to? |
|
120 | - * Set as false to skip this step. |
|
121 | - * @param $contents Allowed children in form of: |
|
122 | - * "$content_model_type: $content_model" |
|
123 | - * @param $attr_includes What attribute collections to register to |
|
124 | - * element? |
|
125 | - * @param $attr What unique attributes does the element define? |
|
126 | - * @note See ElementDef for in-depth descriptions of these parameters. |
|
127 | - * @return Created element definition object, so you |
|
128 | - * can set advanced parameters |
|
129 | - */ |
|
130 | - public function addElement($element, $type, $contents, $attr_includes = array(), $attr = array()) { |
|
131 | - $this->elements[] = $element; |
|
132 | - // parse content_model |
|
133 | - list($content_model_type, $content_model) = $this->parseContents($contents); |
|
134 | - // merge in attribute inclusions |
|
135 | - $this->mergeInAttrIncludes($attr, $attr_includes); |
|
136 | - // add element to content sets |
|
137 | - if ($type) $this->addElementToContentSet($element, $type); |
|
138 | - // create element |
|
139 | - $this->info[$element] = HTMLPurifier_ElementDef::create( |
|
140 | - $content_model, $content_model_type, $attr |
|
141 | - ); |
|
142 | - // literal object $contents means direct child manipulation |
|
143 | - if (!is_string($contents)) $this->info[$element]->child = $contents; |
|
144 | - return $this->info[$element]; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Convenience function that creates a totally blank, non-standalone |
|
149 | - * element. |
|
150 | - * @param $element Name of element to create |
|
151 | - * @return Created element |
|
152 | - */ |
|
153 | - public function addBlankElement($element) { |
|
154 | - if (!isset($this->info[$element])) { |
|
155 | - $this->elements[] = $element; |
|
156 | - $this->info[$element] = new HTMLPurifier_ElementDef(); |
|
157 | - $this->info[$element]->standalone = false; |
|
158 | - } else { |
|
159 | - trigger_error("Definition for $element already exists in module, cannot redefine"); |
|
160 | - } |
|
161 | - return $this->info[$element]; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Convenience function that registers an element to a content set |
|
166 | - * @param Element to register |
|
167 | - * @param Name content set (warning: case sensitive, usually upper-case |
|
168 | - * first letter) |
|
169 | - */ |
|
170 | - public function addElementToContentSet($element, $type) { |
|
171 | - if (!isset($this->content_sets[$type])) $this->content_sets[$type] = ''; |
|
172 | - else $this->content_sets[$type] .= ' | '; |
|
173 | - $this->content_sets[$type] .= $element; |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Convenience function that transforms single-string contents |
|
178 | - * into separate content model and content model type |
|
179 | - * @param $contents Allowed children in form of: |
|
180 | - * "$content_model_type: $content_model" |
|
181 | - * @note If contents is an object, an array of two nulls will be |
|
182 | - * returned, and the callee needs to take the original $contents |
|
183 | - * and use it directly. |
|
184 | - */ |
|
185 | - public function parseContents($contents) { |
|
186 | - if (!is_string($contents)) return array(null, null); // defer |
|
187 | - switch ($contents) { |
|
188 | - // check for shorthand content model forms |
|
189 | - case 'Empty': |
|
190 | - return array('empty', ''); |
|
191 | - case 'Inline': |
|
192 | - return array('optional', 'Inline | #PCDATA'); |
|
193 | - case 'Flow': |
|
194 | - return array('optional', 'Flow | #PCDATA'); |
|
195 | - } |
|
196 | - list($content_model_type, $content_model) = explode(':', $contents); |
|
197 | - $content_model_type = strtolower(trim($content_model_type)); |
|
198 | - $content_model = trim($content_model); |
|
199 | - return array($content_model_type, $content_model); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Convenience function that merges a list of attribute includes into |
|
204 | - * an attribute array. |
|
205 | - * @param $attr Reference to attr array to modify |
|
206 | - * @param $attr_includes Array of includes / string include to merge in |
|
207 | - */ |
|
208 | - public function mergeInAttrIncludes(&$attr, $attr_includes) { |
|
209 | - if (!is_array($attr_includes)) { |
|
210 | - if (empty($attr_includes)) $attr_includes = array(); |
|
211 | - else $attr_includes = array($attr_includes); |
|
212 | - } |
|
213 | - $attr[0] = $attr_includes; |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Convenience function that generates a lookup table with boolean |
|
218 | - * true as value. |
|
219 | - * @param $list List of values to turn into a lookup |
|
220 | - * @note You can also pass an arbitrary number of arguments in |
|
221 | - * place of the regular argument |
|
222 | - * @return Lookup array equivalent of list |
|
223 | - */ |
|
224 | - public function makeLookup($list) { |
|
225 | - if (is_string($list)) $list = func_get_args(); |
|
226 | - $ret = array(); |
|
227 | - foreach ($list as $value) { |
|
228 | - if (is_null($value)) continue; |
|
229 | - $ret[$value] = true; |
|
230 | - } |
|
231 | - return $ret; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * Lazy load construction of the module after determining whether |
|
236 | - * or not it's needed, and also when a finalized configuration object |
|
237 | - * is available. |
|
238 | - * @param $config Instance of HTMLPurifier_Config |
|
239 | - */ |
|
240 | - public function setup($config) {} |
|
21 | + // -- Overloadable ---------------------------------------------------- |
|
22 | + |
|
23 | + /** |
|
24 | + * Short unique string identifier of the module |
|
25 | + */ |
|
26 | + public $name; |
|
27 | + |
|
28 | + /** |
|
29 | + * Informally, a list of elements this module changes. Not used in |
|
30 | + * any significant way. |
|
31 | + */ |
|
32 | + public $elements = array(); |
|
33 | + |
|
34 | + /** |
|
35 | + * Associative array of element names to element definitions. |
|
36 | + * Some definitions may be incomplete, to be merged in later |
|
37 | + * with the full definition. |
|
38 | + */ |
|
39 | + public $info = array(); |
|
40 | + |
|
41 | + /** |
|
42 | + * Associative array of content set names to content set additions. |
|
43 | + * This is commonly used to, say, add an A element to the Inline |
|
44 | + * content set. This corresponds to an internal variable $content_sets |
|
45 | + * and NOT info_content_sets member variable of HTMLDefinition. |
|
46 | + */ |
|
47 | + public $content_sets = array(); |
|
48 | + |
|
49 | + /** |
|
50 | + * Associative array of attribute collection names to attribute |
|
51 | + * collection additions. More rarely used for adding attributes to |
|
52 | + * the global collections. Example is the StyleAttribute module adding |
|
53 | + * the style attribute to the Core. Corresponds to HTMLDefinition's |
|
54 | + * attr_collections->info, since the object's data is only info, |
|
55 | + * with extra behavior associated with it. |
|
56 | + */ |
|
57 | + public $attr_collections = array(); |
|
58 | + |
|
59 | + /** |
|
60 | + * Associative array of deprecated tag name to HTMLPurifier_TagTransform |
|
61 | + */ |
|
62 | + public $info_tag_transform = array(); |
|
63 | + |
|
64 | + /** |
|
65 | + * List of HTMLPurifier_AttrTransform to be performed before validation. |
|
66 | + */ |
|
67 | + public $info_attr_transform_pre = array(); |
|
68 | + |
|
69 | + /** |
|
70 | + * List of HTMLPurifier_AttrTransform to be performed after validation. |
|
71 | + */ |
|
72 | + public $info_attr_transform_post = array(); |
|
73 | + |
|
74 | + /** |
|
75 | + * List of HTMLPurifier_Injector to be performed during well-formedness fixing. |
|
76 | + * An injector will only be invoked if all of it's pre-requisites are met; |
|
77 | + * if an injector fails setup, there will be no error; it will simply be |
|
78 | + * silently disabled. |
|
79 | + */ |
|
80 | + public $info_injector = array(); |
|
81 | + |
|
82 | + /** |
|
83 | + * Boolean flag that indicates whether or not getChildDef is implemented. |
|
84 | + * For optimization reasons: may save a call to a function. Be sure |
|
85 | + * to set it if you do implement getChildDef(), otherwise it will have |
|
86 | + * no effect! |
|
87 | + */ |
|
88 | + public $defines_child_def = false; |
|
89 | + |
|
90 | + /** |
|
91 | + * Boolean flag whether or not this module is safe. If it is not safe, all |
|
92 | + * of its members are unsafe. Modules are safe by default (this might be |
|
93 | + * slightly dangerous, but it doesn't make much sense to force HTML Purifier, |
|
94 | + * which is based off of safe HTML, to explicitly say, "This is safe," even |
|
95 | + * though there are modules which are "unsafe") |
|
96 | + * |
|
97 | + * @note Previously, safety could be applied at an element level granularity. |
|
98 | + * We've removed this ability, so in order to add "unsafe" elements |
|
99 | + * or attributes, a dedicated module with this property set to false |
|
100 | + * must be used. |
|
101 | + */ |
|
102 | + public $safe = true; |
|
103 | + |
|
104 | + /** |
|
105 | + * Retrieves a proper HTMLPurifier_ChildDef subclass based on |
|
106 | + * content_model and content_model_type member variables of |
|
107 | + * the HTMLPurifier_ElementDef class. There is a similar function |
|
108 | + * in HTMLPurifier_HTMLDefinition. |
|
109 | + * @param $def HTMLPurifier_ElementDef instance |
|
110 | + * @return HTMLPurifier_ChildDef subclass |
|
111 | + */ |
|
112 | + public function getChildDef($def) {return false;} |
|
113 | + |
|
114 | + // -- Convenience ----------------------------------------------------- |
|
115 | + |
|
116 | + /** |
|
117 | + * Convenience function that sets up a new element |
|
118 | + * @param $element Name of element to add |
|
119 | + * @param $type What content set should element be registered to? |
|
120 | + * Set as false to skip this step. |
|
121 | + * @param $contents Allowed children in form of: |
|
122 | + * "$content_model_type: $content_model" |
|
123 | + * @param $attr_includes What attribute collections to register to |
|
124 | + * element? |
|
125 | + * @param $attr What unique attributes does the element define? |
|
126 | + * @note See ElementDef for in-depth descriptions of these parameters. |
|
127 | + * @return Created element definition object, so you |
|
128 | + * can set advanced parameters |
|
129 | + */ |
|
130 | + public function addElement($element, $type, $contents, $attr_includes = array(), $attr = array()) { |
|
131 | + $this->elements[] = $element; |
|
132 | + // parse content_model |
|
133 | + list($content_model_type, $content_model) = $this->parseContents($contents); |
|
134 | + // merge in attribute inclusions |
|
135 | + $this->mergeInAttrIncludes($attr, $attr_includes); |
|
136 | + // add element to content sets |
|
137 | + if ($type) $this->addElementToContentSet($element, $type); |
|
138 | + // create element |
|
139 | + $this->info[$element] = HTMLPurifier_ElementDef::create( |
|
140 | + $content_model, $content_model_type, $attr |
|
141 | + ); |
|
142 | + // literal object $contents means direct child manipulation |
|
143 | + if (!is_string($contents)) $this->info[$element]->child = $contents; |
|
144 | + return $this->info[$element]; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Convenience function that creates a totally blank, non-standalone |
|
149 | + * element. |
|
150 | + * @param $element Name of element to create |
|
151 | + * @return Created element |
|
152 | + */ |
|
153 | + public function addBlankElement($element) { |
|
154 | + if (!isset($this->info[$element])) { |
|
155 | + $this->elements[] = $element; |
|
156 | + $this->info[$element] = new HTMLPurifier_ElementDef(); |
|
157 | + $this->info[$element]->standalone = false; |
|
158 | + } else { |
|
159 | + trigger_error("Definition for $element already exists in module, cannot redefine"); |
|
160 | + } |
|
161 | + return $this->info[$element]; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Convenience function that registers an element to a content set |
|
166 | + * @param Element to register |
|
167 | + * @param Name content set (warning: case sensitive, usually upper-case |
|
168 | + * first letter) |
|
169 | + */ |
|
170 | + public function addElementToContentSet($element, $type) { |
|
171 | + if (!isset($this->content_sets[$type])) $this->content_sets[$type] = ''; |
|
172 | + else $this->content_sets[$type] .= ' | '; |
|
173 | + $this->content_sets[$type] .= $element; |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Convenience function that transforms single-string contents |
|
178 | + * into separate content model and content model type |
|
179 | + * @param $contents Allowed children in form of: |
|
180 | + * "$content_model_type: $content_model" |
|
181 | + * @note If contents is an object, an array of two nulls will be |
|
182 | + * returned, and the callee needs to take the original $contents |
|
183 | + * and use it directly. |
|
184 | + */ |
|
185 | + public function parseContents($contents) { |
|
186 | + if (!is_string($contents)) return array(null, null); // defer |
|
187 | + switch ($contents) { |
|
188 | + // check for shorthand content model forms |
|
189 | + case 'Empty': |
|
190 | + return array('empty', ''); |
|
191 | + case 'Inline': |
|
192 | + return array('optional', 'Inline | #PCDATA'); |
|
193 | + case 'Flow': |
|
194 | + return array('optional', 'Flow | #PCDATA'); |
|
195 | + } |
|
196 | + list($content_model_type, $content_model) = explode(':', $contents); |
|
197 | + $content_model_type = strtolower(trim($content_model_type)); |
|
198 | + $content_model = trim($content_model); |
|
199 | + return array($content_model_type, $content_model); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Convenience function that merges a list of attribute includes into |
|
204 | + * an attribute array. |
|
205 | + * @param $attr Reference to attr array to modify |
|
206 | + * @param $attr_includes Array of includes / string include to merge in |
|
207 | + */ |
|
208 | + public function mergeInAttrIncludes(&$attr, $attr_includes) { |
|
209 | + if (!is_array($attr_includes)) { |
|
210 | + if (empty($attr_includes)) $attr_includes = array(); |
|
211 | + else $attr_includes = array($attr_includes); |
|
212 | + } |
|
213 | + $attr[0] = $attr_includes; |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Convenience function that generates a lookup table with boolean |
|
218 | + * true as value. |
|
219 | + * @param $list List of values to turn into a lookup |
|
220 | + * @note You can also pass an arbitrary number of arguments in |
|
221 | + * place of the regular argument |
|
222 | + * @return Lookup array equivalent of list |
|
223 | + */ |
|
224 | + public function makeLookup($list) { |
|
225 | + if (is_string($list)) $list = func_get_args(); |
|
226 | + $ret = array(); |
|
227 | + foreach ($list as $value) { |
|
228 | + if (is_null($value)) continue; |
|
229 | + $ret[$value] = true; |
|
230 | + } |
|
231 | + return $ret; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * Lazy load construction of the module after determining whether |
|
236 | + * or not it's needed, and also when a finalized configuration object |
|
237 | + * is available. |
|
238 | + * @param $config Instance of HTMLPurifier_Config |
|
239 | + */ |
|
240 | + public function setup($config) {} |
|
241 | 241 | |
242 | 242 | } |
243 | 243 |
@@ -109,7 +109,7 @@ |
||
109 | 109 | * @param $def HTMLPurifier_ElementDef instance |
110 | 110 | * @return HTMLPurifier_ChildDef subclass |
111 | 111 | */ |
112 | - public function getChildDef($def) {return false;} |
|
112 | + public function getChildDef($def) {return false; } |
|
113 | 113 | |
114 | 114 | // -- Convenience ----------------------------------------------------- |
115 | 115 |
@@ -134,13 +134,17 @@ discard block |
||
134 | 134 | // merge in attribute inclusions |
135 | 135 | $this->mergeInAttrIncludes($attr, $attr_includes); |
136 | 136 | // add element to content sets |
137 | - if ($type) $this->addElementToContentSet($element, $type); |
|
137 | + if ($type) { |
|
138 | + $this->addElementToContentSet($element, $type); |
|
139 | + } |
|
138 | 140 | // create element |
139 | 141 | $this->info[$element] = HTMLPurifier_ElementDef::create( |
140 | 142 | $content_model, $content_model_type, $attr |
141 | 143 | ); |
142 | 144 | // literal object $contents means direct child manipulation |
143 | - if (!is_string($contents)) $this->info[$element]->child = $contents; |
|
145 | + if (!is_string($contents)) { |
|
146 | + $this->info[$element]->child = $contents; |
|
147 | + } |
|
144 | 148 | return $this->info[$element]; |
145 | 149 | } |
146 | 150 | |
@@ -168,8 +172,11 @@ discard block |
||
168 | 172 | * first letter) |
169 | 173 | */ |
170 | 174 | public function addElementToContentSet($element, $type) { |
171 | - if (!isset($this->content_sets[$type])) $this->content_sets[$type] = ''; |
|
172 | - else $this->content_sets[$type] .= ' | '; |
|
175 | + if (!isset($this->content_sets[$type])) { |
|
176 | + $this->content_sets[$type] = ''; |
|
177 | + } else { |
|
178 | + $this->content_sets[$type] .= ' | '; |
|
179 | + } |
|
173 | 180 | $this->content_sets[$type] .= $element; |
174 | 181 | } |
175 | 182 | |
@@ -183,7 +190,10 @@ discard block |
||
183 | 190 | * and use it directly. |
184 | 191 | */ |
185 | 192 | public function parseContents($contents) { |
186 | - if (!is_string($contents)) return array(null, null); // defer |
|
193 | + if (!is_string($contents)) { |
|
194 | + return array(null, null); |
|
195 | + } |
|
196 | + // defer |
|
187 | 197 | switch ($contents) { |
188 | 198 | // check for shorthand content model forms |
189 | 199 | case 'Empty': |
@@ -207,8 +217,11 @@ discard block |
||
207 | 217 | */ |
208 | 218 | public function mergeInAttrIncludes(&$attr, $attr_includes) { |
209 | 219 | if (!is_array($attr_includes)) { |
210 | - if (empty($attr_includes)) $attr_includes = array(); |
|
211 | - else $attr_includes = array($attr_includes); |
|
220 | + if (empty($attr_includes)) { |
|
221 | + $attr_includes = array(); |
|
222 | + } else { |
|
223 | + $attr_includes = array($attr_includes); |
|
224 | + } |
|
212 | 225 | } |
213 | 226 | $attr[0] = $attr_includes; |
214 | 227 | } |
@@ -222,10 +235,14 @@ discard block |
||
222 | 235 | * @return Lookup array equivalent of list |
223 | 236 | */ |
224 | 237 | public function makeLookup($list) { |
225 | - if (is_string($list)) $list = func_get_args(); |
|
238 | + if (is_string($list)) { |
|
239 | + $list = func_get_args(); |
|
240 | + } |
|
226 | 241 | $ret = array(); |
227 | 242 | foreach ($list as $value) { |
228 | - if (is_null($value)) continue; |
|
243 | + if (is_null($value)) { |
|
244 | + continue; |
|
245 | + } |
|
229 | 246 | $ret[$value] = true; |
230 | 247 | } |
231 | 248 | return $ret; |
@@ -7,24 +7,24 @@ |
||
7 | 7 | class HTMLPurifier_HTMLModule_Bdo extends HTMLPurifier_HTMLModule |
8 | 8 | { |
9 | 9 | |
10 | - public $name = 'Bdo'; |
|
11 | - public $attr_collections = array( |
|
12 | - 'I18N' => array('dir' => false) |
|
13 | - ); |
|
10 | + public $name = 'Bdo'; |
|
11 | + public $attr_collections = array( |
|
12 | + 'I18N' => array('dir' => false) |
|
13 | + ); |
|
14 | 14 | |
15 | - public function setup($config) { |
|
16 | - $bdo = $this->addElement( |
|
17 | - 'bdo', 'Inline', 'Inline', array('Core', 'Lang'), |
|
18 | - array( |
|
19 | - 'dir' => 'Enum#ltr,rtl', // required |
|
20 | - // The Abstract Module specification has the attribute |
|
21 | - // inclusions wrong for bdo: bdo allows Lang |
|
22 | - ) |
|
23 | - ); |
|
24 | - $bdo->attr_transform_post['required-dir'] = new HTMLPurifier_AttrTransform_BdoDir(); |
|
15 | + public function setup($config) { |
|
16 | + $bdo = $this->addElement( |
|
17 | + 'bdo', 'Inline', 'Inline', array('Core', 'Lang'), |
|
18 | + array( |
|
19 | + 'dir' => 'Enum#ltr,rtl', // required |
|
20 | + // The Abstract Module specification has the attribute |
|
21 | + // inclusions wrong for bdo: bdo allows Lang |
|
22 | + ) |
|
23 | + ); |
|
24 | + $bdo->attr_transform_post['required-dir'] = new HTMLPurifier_AttrTransform_BdoDir(); |
|
25 | 25 | |
26 | - $this->attr_collections['I18N']['dir'] = 'Enum#ltr,rtl'; |
|
27 | - } |
|
26 | + $this->attr_collections['I18N']['dir'] = 'Enum#ltr,rtl'; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |
30 | 30 |
@@ -2,24 +2,24 @@ |
||
2 | 2 | |
3 | 3 | class HTMLPurifier_HTMLModule_CommonAttributes extends HTMLPurifier_HTMLModule |
4 | 4 | { |
5 | - public $name = 'CommonAttributes'; |
|
5 | + public $name = 'CommonAttributes'; |
|
6 | 6 | |
7 | - public $attr_collections = array( |
|
8 | - 'Core' => array( |
|
9 | - 0 => array('Style'), |
|
10 | - // 'xml:space' => false, |
|
11 | - 'class' => 'Class', |
|
12 | - 'id' => 'ID', |
|
13 | - 'title' => 'CDATA', |
|
14 | - ), |
|
15 | - 'Lang' => array(), |
|
16 | - 'I18N' => array( |
|
17 | - 0 => array('Lang'), // proprietary, for xml:lang/lang |
|
18 | - ), |
|
19 | - 'Common' => array( |
|
20 | - 0 => array('Core', 'I18N') |
|
21 | - ) |
|
22 | - ); |
|
7 | + public $attr_collections = array( |
|
8 | + 'Core' => array( |
|
9 | + 0 => array('Style'), |
|
10 | + // 'xml:space' => false, |
|
11 | + 'class' => 'Class', |
|
12 | + 'id' => 'ID', |
|
13 | + 'title' => 'CDATA', |
|
14 | + ), |
|
15 | + 'Lang' => array(), |
|
16 | + 'I18N' => array( |
|
17 | + 0 => array('Lang'), // proprietary, for xml:lang/lang |
|
18 | + ), |
|
19 | + 'Common' => array( |
|
20 | + 0 => array('Core', 'I18N') |
|
21 | + ) |
|
22 | + ); |
|
23 | 23 | |
24 | 24 | } |
25 | 25 |
@@ -7,31 +7,31 @@ |
||
7 | 7 | class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule |
8 | 8 | { |
9 | 9 | |
10 | - public $name = 'Edit'; |
|
11 | - |
|
12 | - public function setup($config) { |
|
13 | - $contents = 'Chameleon: #PCDATA | Inline ! #PCDATA | Flow'; |
|
14 | - $attr = array( |
|
15 | - 'cite' => 'URI', |
|
16 | - // 'datetime' => 'Datetime', // not implemented |
|
17 | - ); |
|
18 | - $this->addElement('del', 'Inline', $contents, 'Common', $attr); |
|
19 | - $this->addElement('ins', 'Inline', $contents, 'Common', $attr); |
|
20 | - } |
|
21 | - |
|
22 | - // HTML 4.01 specifies that ins/del must not contain block |
|
23 | - // elements when used in an inline context, chameleon is |
|
24 | - // a complicated workaround to acheive this effect |
|
25 | - |
|
26 | - // Inline context ! Block context (exclamation mark is |
|
27 | - // separator, see getChildDef for parsing) |
|
28 | - |
|
29 | - public $defines_child_def = true; |
|
30 | - public function getChildDef($def) { |
|
31 | - if ($def->content_model_type != 'chameleon') return false; |
|
32 | - $value = explode('!', $def->content_model); |
|
33 | - return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]); |
|
34 | - } |
|
10 | + public $name = 'Edit'; |
|
11 | + |
|
12 | + public function setup($config) { |
|
13 | + $contents = 'Chameleon: #PCDATA | Inline ! #PCDATA | Flow'; |
|
14 | + $attr = array( |
|
15 | + 'cite' => 'URI', |
|
16 | + // 'datetime' => 'Datetime', // not implemented |
|
17 | + ); |
|
18 | + $this->addElement('del', 'Inline', $contents, 'Common', $attr); |
|
19 | + $this->addElement('ins', 'Inline', $contents, 'Common', $attr); |
|
20 | + } |
|
21 | + |
|
22 | + // HTML 4.01 specifies that ins/del must not contain block |
|
23 | + // elements when used in an inline context, chameleon is |
|
24 | + // a complicated workaround to acheive this effect |
|
25 | + |
|
26 | + // Inline context ! Block context (exclamation mark is |
|
27 | + // separator, see getChildDef for parsing) |
|
28 | + |
|
29 | + public $defines_child_def = true; |
|
30 | + public function getChildDef($def) { |
|
31 | + if ($def->content_model_type != 'chameleon') return false; |
|
32 | + $value = explode('!', $def->content_model); |
|
33 | + return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
37 | 37 |
@@ -28,7 +28,9 @@ |
||
28 | 28 | |
29 | 29 | public $defines_child_def = true; |
30 | 30 | public function getChildDef($def) { |
31 | - if ($def->content_model_type != 'chameleon') return false; |
|
31 | + if ($def->content_model_type != 'chameleon') { |
|
32 | + return false; |
|
33 | + } |
|
32 | 34 | $value = explode('!', $def->content_model); |
33 | 35 | return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]); |
34 | 36 | } |
@@ -5,115 +5,115 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_HTMLModule_Forms extends HTMLPurifier_HTMLModule |
7 | 7 | { |
8 | - public $name = 'Forms'; |
|
9 | - public $safe = false; |
|
10 | - |
|
11 | - public $content_sets = array( |
|
12 | - 'Block' => 'Form', |
|
13 | - 'Inline' => 'Formctrl', |
|
14 | - ); |
|
15 | - |
|
16 | - public function setup($config) { |
|
17 | - $form = $this->addElement('form', 'Form', |
|
18 | - 'Required: Heading | List | Block | fieldset', 'Common', array( |
|
19 | - 'accept' => 'ContentTypes', |
|
20 | - 'accept-charset' => 'Charsets', |
|
21 | - 'action*' => 'URI', |
|
22 | - 'method' => 'Enum#get,post', |
|
23 | - // really ContentType, but these two are the only ones used today |
|
24 | - 'enctype' => 'Enum#application/x-www-form-urlencoded,multipart/form-data', |
|
25 | - )); |
|
26 | - $form->excludes = array('form' => true); |
|
27 | - |
|
28 | - $input = $this->addElement('input', 'Formctrl', 'Empty', 'Common', array( |
|
29 | - 'accept' => 'ContentTypes', |
|
30 | - 'accesskey' => 'Character', |
|
31 | - 'alt' => 'Text', |
|
32 | - 'checked' => 'Bool#checked', |
|
33 | - 'disabled' => 'Bool#disabled', |
|
34 | - 'maxlength' => 'Number', |
|
35 | - 'name' => 'CDATA', |
|
36 | - 'readonly' => 'Bool#readonly', |
|
37 | - 'size' => 'Number', |
|
38 | - 'src' => 'URI#embedded', |
|
39 | - 'tabindex' => 'Number', |
|
40 | - 'type' => 'Enum#text,password,checkbox,button,radio,submit,reset,file,hidden,image', |
|
41 | - 'value' => 'CDATA', |
|
42 | - )); |
|
43 | - $input->attr_transform_post[] = new HTMLPurifier_AttrTransform_Input(); |
|
44 | - |
|
45 | - $this->addElement('select', 'Formctrl', 'Required: optgroup | option', 'Common', array( |
|
46 | - 'disabled' => 'Bool#disabled', |
|
47 | - 'multiple' => 'Bool#multiple', |
|
48 | - 'name' => 'CDATA', |
|
49 | - 'size' => 'Number', |
|
50 | - 'tabindex' => 'Number', |
|
51 | - )); |
|
52 | - |
|
53 | - $this->addElement('option', false, 'Optional: #PCDATA', 'Common', array( |
|
54 | - 'disabled' => 'Bool#disabled', |
|
55 | - 'label' => 'Text', |
|
56 | - 'selected' => 'Bool#selected', |
|
57 | - 'value' => 'CDATA', |
|
58 | - )); |
|
59 | - // It's illegal for there to be more than one selected, but not |
|
60 | - // be multiple. Also, no selected means undefined behavior. This might |
|
61 | - // be difficult to implement; perhaps an injector, or a context variable. |
|
62 | - |
|
63 | - $textarea = $this->addElement('textarea', 'Formctrl', 'Optional: #PCDATA', 'Common', array( |
|
64 | - 'accesskey' => 'Character', |
|
65 | - 'cols*' => 'Number', |
|
66 | - 'disabled' => 'Bool#disabled', |
|
67 | - 'name' => 'CDATA', |
|
68 | - 'readonly' => 'Bool#readonly', |
|
69 | - 'rows*' => 'Number', |
|
70 | - 'tabindex' => 'Number', |
|
71 | - )); |
|
72 | - $textarea->attr_transform_pre[] = new HTMLPurifier_AttrTransform_Textarea(); |
|
73 | - |
|
74 | - $button = $this->addElement('button', 'Formctrl', 'Optional: #PCDATA | Heading | List | Block | Inline', 'Common', array( |
|
75 | - 'accesskey' => 'Character', |
|
76 | - 'disabled' => 'Bool#disabled', |
|
77 | - 'name' => 'CDATA', |
|
78 | - 'tabindex' => 'Number', |
|
79 | - 'type' => 'Enum#button,submit,reset', |
|
80 | - 'value' => 'CDATA', |
|
81 | - )); |
|
82 | - |
|
83 | - // For exclusions, ideally we'd specify content sets, not literal elements |
|
84 | - $button->excludes = $this->makeLookup( |
|
85 | - 'form', 'fieldset', // Form |
|
86 | - 'input', 'select', 'textarea', 'label', 'button', // Formctrl |
|
87 | - 'a', // as per HTML 4.01 spec, this is omitted by modularization |
|
88 | - 'isindex', 'iframe' // legacy items |
|
89 | - ); |
|
90 | - |
|
91 | - // Extra exclusion: img usemap="" is not permitted within this element. |
|
92 | - // We'll omit this for now, since we don't have any good way of |
|
93 | - // indicating it yet. |
|
94 | - |
|
95 | - // This is HIGHLY user-unfriendly; we need a custom child-def for this |
|
96 | - $this->addElement('fieldset', 'Form', 'Custom: (#WS?,legend,(Flow|#PCDATA)*)', 'Common'); |
|
97 | - |
|
98 | - $label = $this->addElement('label', 'Formctrl', 'Optional: #PCDATA | Inline', 'Common', array( |
|
99 | - 'accesskey' => 'Character', |
|
100 | - // 'for' => 'IDREF', // IDREF not implemented, cannot allow |
|
101 | - )); |
|
102 | - $label->excludes = array('label' => true); |
|
103 | - |
|
104 | - $this->addElement('legend', false, 'Optional: #PCDATA | Inline', 'Common', array( |
|
105 | - 'accesskey' => 'Character', |
|
106 | - )); |
|
107 | - |
|
108 | - $this->addElement('optgroup', false, 'Required: option', 'Common', array( |
|
109 | - 'disabled' => 'Bool#disabled', |
|
110 | - 'label*' => 'Text', |
|
111 | - )); |
|
112 | - |
|
113 | - // Don't forget an injector for <isindex>. This one's a little complex |
|
114 | - // because it maps to multiple elements. |
|
115 | - |
|
116 | - } |
|
8 | + public $name = 'Forms'; |
|
9 | + public $safe = false; |
|
10 | + |
|
11 | + public $content_sets = array( |
|
12 | + 'Block' => 'Form', |
|
13 | + 'Inline' => 'Formctrl', |
|
14 | + ); |
|
15 | + |
|
16 | + public function setup($config) { |
|
17 | + $form = $this->addElement('form', 'Form', |
|
18 | + 'Required: Heading | List | Block | fieldset', 'Common', array( |
|
19 | + 'accept' => 'ContentTypes', |
|
20 | + 'accept-charset' => 'Charsets', |
|
21 | + 'action*' => 'URI', |
|
22 | + 'method' => 'Enum#get,post', |
|
23 | + // really ContentType, but these two are the only ones used today |
|
24 | + 'enctype' => 'Enum#application/x-www-form-urlencoded,multipart/form-data', |
|
25 | + )); |
|
26 | + $form->excludes = array('form' => true); |
|
27 | + |
|
28 | + $input = $this->addElement('input', 'Formctrl', 'Empty', 'Common', array( |
|
29 | + 'accept' => 'ContentTypes', |
|
30 | + 'accesskey' => 'Character', |
|
31 | + 'alt' => 'Text', |
|
32 | + 'checked' => 'Bool#checked', |
|
33 | + 'disabled' => 'Bool#disabled', |
|
34 | + 'maxlength' => 'Number', |
|
35 | + 'name' => 'CDATA', |
|
36 | + 'readonly' => 'Bool#readonly', |
|
37 | + 'size' => 'Number', |
|
38 | + 'src' => 'URI#embedded', |
|
39 | + 'tabindex' => 'Number', |
|
40 | + 'type' => 'Enum#text,password,checkbox,button,radio,submit,reset,file,hidden,image', |
|
41 | + 'value' => 'CDATA', |
|
42 | + )); |
|
43 | + $input->attr_transform_post[] = new HTMLPurifier_AttrTransform_Input(); |
|
44 | + |
|
45 | + $this->addElement('select', 'Formctrl', 'Required: optgroup | option', 'Common', array( |
|
46 | + 'disabled' => 'Bool#disabled', |
|
47 | + 'multiple' => 'Bool#multiple', |
|
48 | + 'name' => 'CDATA', |
|
49 | + 'size' => 'Number', |
|
50 | + 'tabindex' => 'Number', |
|
51 | + )); |
|
52 | + |
|
53 | + $this->addElement('option', false, 'Optional: #PCDATA', 'Common', array( |
|
54 | + 'disabled' => 'Bool#disabled', |
|
55 | + 'label' => 'Text', |
|
56 | + 'selected' => 'Bool#selected', |
|
57 | + 'value' => 'CDATA', |
|
58 | + )); |
|
59 | + // It's illegal for there to be more than one selected, but not |
|
60 | + // be multiple. Also, no selected means undefined behavior. This might |
|
61 | + // be difficult to implement; perhaps an injector, or a context variable. |
|
62 | + |
|
63 | + $textarea = $this->addElement('textarea', 'Formctrl', 'Optional: #PCDATA', 'Common', array( |
|
64 | + 'accesskey' => 'Character', |
|
65 | + 'cols*' => 'Number', |
|
66 | + 'disabled' => 'Bool#disabled', |
|
67 | + 'name' => 'CDATA', |
|
68 | + 'readonly' => 'Bool#readonly', |
|
69 | + 'rows*' => 'Number', |
|
70 | + 'tabindex' => 'Number', |
|
71 | + )); |
|
72 | + $textarea->attr_transform_pre[] = new HTMLPurifier_AttrTransform_Textarea(); |
|
73 | + |
|
74 | + $button = $this->addElement('button', 'Formctrl', 'Optional: #PCDATA | Heading | List | Block | Inline', 'Common', array( |
|
75 | + 'accesskey' => 'Character', |
|
76 | + 'disabled' => 'Bool#disabled', |
|
77 | + 'name' => 'CDATA', |
|
78 | + 'tabindex' => 'Number', |
|
79 | + 'type' => 'Enum#button,submit,reset', |
|
80 | + 'value' => 'CDATA', |
|
81 | + )); |
|
82 | + |
|
83 | + // For exclusions, ideally we'd specify content sets, not literal elements |
|
84 | + $button->excludes = $this->makeLookup( |
|
85 | + 'form', 'fieldset', // Form |
|
86 | + 'input', 'select', 'textarea', 'label', 'button', // Formctrl |
|
87 | + 'a', // as per HTML 4.01 spec, this is omitted by modularization |
|
88 | + 'isindex', 'iframe' // legacy items |
|
89 | + ); |
|
90 | + |
|
91 | + // Extra exclusion: img usemap="" is not permitted within this element. |
|
92 | + // We'll omit this for now, since we don't have any good way of |
|
93 | + // indicating it yet. |
|
94 | + |
|
95 | + // This is HIGHLY user-unfriendly; we need a custom child-def for this |
|
96 | + $this->addElement('fieldset', 'Form', 'Custom: (#WS?,legend,(Flow|#PCDATA)*)', 'Common'); |
|
97 | + |
|
98 | + $label = $this->addElement('label', 'Formctrl', 'Optional: #PCDATA | Inline', 'Common', array( |
|
99 | + 'accesskey' => 'Character', |
|
100 | + // 'for' => 'IDREF', // IDREF not implemented, cannot allow |
|
101 | + )); |
|
102 | + $label->excludes = array('label' => true); |
|
103 | + |
|
104 | + $this->addElement('legend', false, 'Optional: #PCDATA | Inline', 'Common', array( |
|
105 | + 'accesskey' => 'Character', |
|
106 | + )); |
|
107 | + |
|
108 | + $this->addElement('optgroup', false, 'Required: option', 'Common', array( |
|
109 | + 'disabled' => 'Bool#disabled', |
|
110 | + 'label*' => 'Text', |
|
111 | + )); |
|
112 | + |
|
113 | + // Don't forget an injector for <isindex>. This one's a little complex |
|
114 | + // because it maps to multiple elements. |
|
115 | + |
|
116 | + } |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // vim: et sw=4 sts=4 |
@@ -6,25 +6,25 @@ |
||
6 | 6 | class HTMLPurifier_HTMLModule_Hypertext extends HTMLPurifier_HTMLModule |
7 | 7 | { |
8 | 8 | |
9 | - public $name = 'Hypertext'; |
|
9 | + public $name = 'Hypertext'; |
|
10 | 10 | |
11 | - public function setup($config) { |
|
12 | - $a = $this->addElement( |
|
13 | - 'a', 'Inline', 'Inline', 'Common', |
|
14 | - array( |
|
15 | - // 'accesskey' => 'Character', |
|
16 | - // 'charset' => 'Charset', |
|
17 | - 'href' => 'URI', |
|
18 | - // 'hreflang' => 'LanguageCode', |
|
19 | - 'rel' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rel'), |
|
20 | - 'rev' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rev'), |
|
21 | - // 'tabindex' => 'Number', |
|
22 | - // 'type' => 'ContentType', |
|
23 | - ) |
|
24 | - ); |
|
25 | - $a->formatting = true; |
|
26 | - $a->excludes = array('a' => true); |
|
27 | - } |
|
11 | + public function setup($config) { |
|
12 | + $a = $this->addElement( |
|
13 | + 'a', 'Inline', 'Inline', 'Common', |
|
14 | + array( |
|
15 | + // 'accesskey' => 'Character', |
|
16 | + // 'charset' => 'Charset', |
|
17 | + 'href' => 'URI', |
|
18 | + // 'hreflang' => 'LanguageCode', |
|
19 | + 'rel' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rel'), |
|
20 | + 'rev' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rev'), |
|
21 | + // 'tabindex' => 'Number', |
|
22 | + // 'type' => 'ContentType', |
|
23 | + ) |
|
24 | + ); |
|
25 | + $a->formatting = true; |
|
26 | + $a->excludes = array('a' => true); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |
30 | 30 |
@@ -10,28 +10,28 @@ |
||
10 | 10 | class HTMLPurifier_HTMLModule_Iframe extends HTMLPurifier_HTMLModule |
11 | 11 | { |
12 | 12 | |
13 | - public $name = 'Iframe'; |
|
14 | - public $safe = false; |
|
13 | + public $name = 'Iframe'; |
|
14 | + public $safe = false; |
|
15 | 15 | |
16 | - public function setup($config) { |
|
17 | - if ($config->get('HTML.SafeIframe')) { |
|
18 | - $this->safe = true; |
|
19 | - } |
|
20 | - $this->addElement( |
|
21 | - 'iframe', 'Inline', 'Flow', 'Common', |
|
22 | - array( |
|
23 | - 'src' => 'URI#embedded', |
|
24 | - 'width' => 'Length', |
|
25 | - 'height' => 'Length', |
|
26 | - 'name' => 'ID', |
|
27 | - 'scrolling' => 'Enum#yes,no,auto', |
|
28 | - 'frameborder' => 'Enum#0,1', |
|
29 | - 'longdesc' => 'URI', |
|
30 | - 'marginheight' => 'Pixels', |
|
31 | - 'marginwidth' => 'Pixels', |
|
32 | - ) |
|
33 | - ); |
|
34 | - } |
|
16 | + public function setup($config) { |
|
17 | + if ($config->get('HTML.SafeIframe')) { |
|
18 | + $this->safe = true; |
|
19 | + } |
|
20 | + $this->addElement( |
|
21 | + 'iframe', 'Inline', 'Flow', 'Common', |
|
22 | + array( |
|
23 | + 'src' => 'URI#embedded', |
|
24 | + 'width' => 'Length', |
|
25 | + 'height' => 'Length', |
|
26 | + 'name' => 'ID', |
|
27 | + 'scrolling' => 'Enum#yes,no,auto', |
|
28 | + 'frameborder' => 'Enum#0,1', |
|
29 | + 'longdesc' => 'URI', |
|
30 | + 'marginheight' => 'Pixels', |
|
31 | + 'marginwidth' => 'Pixels', |
|
32 | + ) |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
37 | 37 |
@@ -8,32 +8,32 @@ |
||
8 | 8 | class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule |
9 | 9 | { |
10 | 10 | |
11 | - public $name = 'Image'; |
|
11 | + public $name = 'Image'; |
|
12 | 12 | |
13 | - public function setup($config) { |
|
14 | - $max = $config->get('HTML.MaxImgLength'); |
|
15 | - $img = $this->addElement( |
|
16 | - 'img', 'Inline', 'Empty', 'Common', |
|
17 | - array( |
|
18 | - 'alt*' => 'Text', |
|
19 | - // According to the spec, it's Length, but percents can |
|
20 | - // be abused, so we allow only Pixels. |
|
21 | - 'height' => 'Pixels#' . $max, |
|
22 | - 'width' => 'Pixels#' . $max, |
|
23 | - 'longdesc' => 'URI', |
|
24 | - 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded |
|
25 | - ) |
|
26 | - ); |
|
27 | - if ($max === null || $config->get('HTML.Trusted')) { |
|
28 | - $img->attr['height'] = |
|
29 | - $img->attr['width'] = 'Length'; |
|
30 | - } |
|
13 | + public function setup($config) { |
|
14 | + $max = $config->get('HTML.MaxImgLength'); |
|
15 | + $img = $this->addElement( |
|
16 | + 'img', 'Inline', 'Empty', 'Common', |
|
17 | + array( |
|
18 | + 'alt*' => 'Text', |
|
19 | + // According to the spec, it's Length, but percents can |
|
20 | + // be abused, so we allow only Pixels. |
|
21 | + 'height' => 'Pixels#' . $max, |
|
22 | + 'width' => 'Pixels#' . $max, |
|
23 | + 'longdesc' => 'URI', |
|
24 | + 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded |
|
25 | + ) |
|
26 | + ); |
|
27 | + if ($max === null || $config->get('HTML.Trusted')) { |
|
28 | + $img->attr['height'] = |
|
29 | + $img->attr['width'] = 'Length'; |
|
30 | + } |
|
31 | 31 | |
32 | - // kind of strange, but splitting things up would be inefficient |
|
33 | - $img->attr_transform_pre[] = |
|
34 | - $img->attr_transform_post[] = |
|
35 | - new HTMLPurifier_AttrTransform_ImgRequired(); |
|
36 | - } |
|
32 | + // kind of strange, but splitting things up would be inefficient |
|
33 | + $img->attr_transform_pre[] = |
|
34 | + $img->attr_transform_post[] = |
|
35 | + new HTMLPurifier_AttrTransform_ImgRequired(); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
39 | 39 |
@@ -19,140 +19,140 @@ |
||
19 | 19 | class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule |
20 | 20 | { |
21 | 21 | |
22 | - public $name = 'Legacy'; |
|
22 | + public $name = 'Legacy'; |
|
23 | 23 | |
24 | - public function setup($config) { |
|
25 | - |
|
26 | - $this->addElement('basefont', 'Inline', 'Empty', false, array( |
|
27 | - 'color' => 'Color', |
|
28 | - 'face' => 'Text', // extremely broad, we should |
|
29 | - 'size' => 'Text', // tighten it |
|
30 | - 'id' => 'ID' |
|
31 | - )); |
|
32 | - $this->addElement('center', 'Block', 'Flow', 'Common'); |
|
33 | - $this->addElement('dir', 'Block', 'Required: li', 'Common', array( |
|
34 | - 'compact' => 'Bool#compact' |
|
35 | - )); |
|
36 | - $this->addElement('font', 'Inline', 'Inline', array('Core', 'I18N'), array( |
|
37 | - 'color' => 'Color', |
|
38 | - 'face' => 'Text', // extremely broad, we should |
|
39 | - 'size' => 'Text', // tighten it |
|
40 | - )); |
|
41 | - $this->addElement('menu', 'Block', 'Required: li', 'Common', array( |
|
42 | - 'compact' => 'Bool#compact' |
|
43 | - )); |
|
44 | - |
|
45 | - $s = $this->addElement('s', 'Inline', 'Inline', 'Common'); |
|
46 | - $s->formatting = true; |
|
47 | - |
|
48 | - $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common'); |
|
49 | - $strike->formatting = true; |
|
50 | - |
|
51 | - $u = $this->addElement('u', 'Inline', 'Inline', 'Common'); |
|
52 | - $u->formatting = true; |
|
53 | - |
|
54 | - // setup modifications to old elements |
|
55 | - |
|
56 | - $align = 'Enum#left,right,center,justify'; |
|
57 | - |
|
58 | - $address = $this->addBlankElement('address'); |
|
59 | - $address->content_model = 'Inline | #PCDATA | p'; |
|
60 | - $address->content_model_type = 'optional'; |
|
61 | - $address->child = false; |
|
62 | - |
|
63 | - $blockquote = $this->addBlankElement('blockquote'); |
|
64 | - $blockquote->content_model = 'Flow | #PCDATA'; |
|
65 | - $blockquote->content_model_type = 'optional'; |
|
66 | - $blockquote->child = false; |
|
67 | - |
|
68 | - $br = $this->addBlankElement('br'); |
|
69 | - $br->attr['clear'] = 'Enum#left,all,right,none'; |
|
70 | - |
|
71 | - $caption = $this->addBlankElement('caption'); |
|
72 | - $caption->attr['align'] = 'Enum#top,bottom,left,right'; |
|
73 | - |
|
74 | - $div = $this->addBlankElement('div'); |
|
75 | - $div->attr['align'] = $align; |
|
76 | - |
|
77 | - $dl = $this->addBlankElement('dl'); |
|
78 | - $dl->attr['compact'] = 'Bool#compact'; |
|
79 | - |
|
80 | - for ($i = 1; $i <= 6; $i++) { |
|
81 | - $h = $this->addBlankElement("h$i"); |
|
82 | - $h->attr['align'] = $align; |
|
83 | - } |
|
84 | - |
|
85 | - $hr = $this->addBlankElement('hr'); |
|
86 | - $hr->attr['align'] = $align; |
|
87 | - $hr->attr['noshade'] = 'Bool#noshade'; |
|
88 | - $hr->attr['size'] = 'Pixels'; |
|
89 | - $hr->attr['width'] = 'Length'; |
|
90 | - |
|
91 | - $img = $this->addBlankElement('img'); |
|
92 | - $img->attr['align'] = 'IAlign'; |
|
93 | - $img->attr['border'] = 'Pixels'; |
|
94 | - $img->attr['hspace'] = 'Pixels'; |
|
95 | - $img->attr['vspace'] = 'Pixels'; |
|
96 | - |
|
97 | - // figure out this integer business |
|
98 | - |
|
99 | - $li = $this->addBlankElement('li'); |
|
100 | - $li->attr['value'] = new HTMLPurifier_AttrDef_Integer(); |
|
101 | - $li->attr['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle'; |
|
102 | - |
|
103 | - $ol = $this->addBlankElement('ol'); |
|
104 | - $ol->attr['compact'] = 'Bool#compact'; |
|
105 | - $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer(); |
|
106 | - $ol->attr['type'] = 'Enum#s:1,i,I,a,A'; |
|
107 | - |
|
108 | - $p = $this->addBlankElement('p'); |
|
109 | - $p->attr['align'] = $align; |
|
110 | - |
|
111 | - $pre = $this->addBlankElement('pre'); |
|
112 | - $pre->attr['width'] = 'Number'; |
|
113 | - |
|
114 | - // script omitted |
|
115 | - |
|
116 | - $table = $this->addBlankElement('table'); |
|
117 | - $table->attr['align'] = 'Enum#left,center,right'; |
|
118 | - $table->attr['bgcolor'] = 'Color'; |
|
119 | - |
|
120 | - $tr = $this->addBlankElement('tr'); |
|
121 | - $tr->attr['bgcolor'] = 'Color'; |
|
122 | - |
|
123 | - $th = $this->addBlankElement('th'); |
|
124 | - $th->attr['bgcolor'] = 'Color'; |
|
125 | - $th->attr['height'] = 'Length'; |
|
126 | - $th->attr['nowrap'] = 'Bool#nowrap'; |
|
127 | - $th->attr['width'] = 'Length'; |
|
128 | - |
|
129 | - $td = $this->addBlankElement('td'); |
|
130 | - $td->attr['bgcolor'] = 'Color'; |
|
131 | - $td->attr['height'] = 'Length'; |
|
132 | - $td->attr['nowrap'] = 'Bool#nowrap'; |
|
133 | - $td->attr['width'] = 'Length'; |
|
24 | + public function setup($config) { |
|
25 | + |
|
26 | + $this->addElement('basefont', 'Inline', 'Empty', false, array( |
|
27 | + 'color' => 'Color', |
|
28 | + 'face' => 'Text', // extremely broad, we should |
|
29 | + 'size' => 'Text', // tighten it |
|
30 | + 'id' => 'ID' |
|
31 | + )); |
|
32 | + $this->addElement('center', 'Block', 'Flow', 'Common'); |
|
33 | + $this->addElement('dir', 'Block', 'Required: li', 'Common', array( |
|
34 | + 'compact' => 'Bool#compact' |
|
35 | + )); |
|
36 | + $this->addElement('font', 'Inline', 'Inline', array('Core', 'I18N'), array( |
|
37 | + 'color' => 'Color', |
|
38 | + 'face' => 'Text', // extremely broad, we should |
|
39 | + 'size' => 'Text', // tighten it |
|
40 | + )); |
|
41 | + $this->addElement('menu', 'Block', 'Required: li', 'Common', array( |
|
42 | + 'compact' => 'Bool#compact' |
|
43 | + )); |
|
44 | + |
|
45 | + $s = $this->addElement('s', 'Inline', 'Inline', 'Common'); |
|
46 | + $s->formatting = true; |
|
47 | + |
|
48 | + $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common'); |
|
49 | + $strike->formatting = true; |
|
50 | + |
|
51 | + $u = $this->addElement('u', 'Inline', 'Inline', 'Common'); |
|
52 | + $u->formatting = true; |
|
53 | + |
|
54 | + // setup modifications to old elements |
|
55 | + |
|
56 | + $align = 'Enum#left,right,center,justify'; |
|
57 | + |
|
58 | + $address = $this->addBlankElement('address'); |
|
59 | + $address->content_model = 'Inline | #PCDATA | p'; |
|
60 | + $address->content_model_type = 'optional'; |
|
61 | + $address->child = false; |
|
62 | + |
|
63 | + $blockquote = $this->addBlankElement('blockquote'); |
|
64 | + $blockquote->content_model = 'Flow | #PCDATA'; |
|
65 | + $blockquote->content_model_type = 'optional'; |
|
66 | + $blockquote->child = false; |
|
67 | + |
|
68 | + $br = $this->addBlankElement('br'); |
|
69 | + $br->attr['clear'] = 'Enum#left,all,right,none'; |
|
70 | + |
|
71 | + $caption = $this->addBlankElement('caption'); |
|
72 | + $caption->attr['align'] = 'Enum#top,bottom,left,right'; |
|
73 | + |
|
74 | + $div = $this->addBlankElement('div'); |
|
75 | + $div->attr['align'] = $align; |
|
76 | + |
|
77 | + $dl = $this->addBlankElement('dl'); |
|
78 | + $dl->attr['compact'] = 'Bool#compact'; |
|
79 | + |
|
80 | + for ($i = 1; $i <= 6; $i++) { |
|
81 | + $h = $this->addBlankElement("h$i"); |
|
82 | + $h->attr['align'] = $align; |
|
83 | + } |
|
84 | + |
|
85 | + $hr = $this->addBlankElement('hr'); |
|
86 | + $hr->attr['align'] = $align; |
|
87 | + $hr->attr['noshade'] = 'Bool#noshade'; |
|
88 | + $hr->attr['size'] = 'Pixels'; |
|
89 | + $hr->attr['width'] = 'Length'; |
|
90 | + |
|
91 | + $img = $this->addBlankElement('img'); |
|
92 | + $img->attr['align'] = 'IAlign'; |
|
93 | + $img->attr['border'] = 'Pixels'; |
|
94 | + $img->attr['hspace'] = 'Pixels'; |
|
95 | + $img->attr['vspace'] = 'Pixels'; |
|
96 | + |
|
97 | + // figure out this integer business |
|
98 | + |
|
99 | + $li = $this->addBlankElement('li'); |
|
100 | + $li->attr['value'] = new HTMLPurifier_AttrDef_Integer(); |
|
101 | + $li->attr['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle'; |
|
102 | + |
|
103 | + $ol = $this->addBlankElement('ol'); |
|
104 | + $ol->attr['compact'] = 'Bool#compact'; |
|
105 | + $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer(); |
|
106 | + $ol->attr['type'] = 'Enum#s:1,i,I,a,A'; |
|
107 | + |
|
108 | + $p = $this->addBlankElement('p'); |
|
109 | + $p->attr['align'] = $align; |
|
110 | + |
|
111 | + $pre = $this->addBlankElement('pre'); |
|
112 | + $pre->attr['width'] = 'Number'; |
|
113 | + |
|
114 | + // script omitted |
|
115 | + |
|
116 | + $table = $this->addBlankElement('table'); |
|
117 | + $table->attr['align'] = 'Enum#left,center,right'; |
|
118 | + $table->attr['bgcolor'] = 'Color'; |
|
119 | + |
|
120 | + $tr = $this->addBlankElement('tr'); |
|
121 | + $tr->attr['bgcolor'] = 'Color'; |
|
122 | + |
|
123 | + $th = $this->addBlankElement('th'); |
|
124 | + $th->attr['bgcolor'] = 'Color'; |
|
125 | + $th->attr['height'] = 'Length'; |
|
126 | + $th->attr['nowrap'] = 'Bool#nowrap'; |
|
127 | + $th->attr['width'] = 'Length'; |
|
128 | + |
|
129 | + $td = $this->addBlankElement('td'); |
|
130 | + $td->attr['bgcolor'] = 'Color'; |
|
131 | + $td->attr['height'] = 'Length'; |
|
132 | + $td->attr['nowrap'] = 'Bool#nowrap'; |
|
133 | + $td->attr['width'] = 'Length'; |
|
134 | 134 | |
135 | - $ul = $this->addBlankElement('ul'); |
|
136 | - $ul->attr['compact'] = 'Bool#compact'; |
|
137 | - $ul->attr['type'] = 'Enum#square,disc,circle'; |
|
135 | + $ul = $this->addBlankElement('ul'); |
|
136 | + $ul->attr['compact'] = 'Bool#compact'; |
|
137 | + $ul->attr['type'] = 'Enum#square,disc,circle'; |
|
138 | 138 | |
139 | - // "safe" modifications to "unsafe" elements |
|
140 | - // WARNING: If you want to add support for an unsafe, legacy |
|
141 | - // attribute, make a new TrustedLegacy module with the trusted |
|
142 | - // bit set appropriately |
|
139 | + // "safe" modifications to "unsafe" elements |
|
140 | + // WARNING: If you want to add support for an unsafe, legacy |
|
141 | + // attribute, make a new TrustedLegacy module with the trusted |
|
142 | + // bit set appropriately |
|
143 | 143 | |
144 | - $form = $this->addBlankElement('form'); |
|
145 | - $form->content_model = 'Flow | #PCDATA'; |
|
146 | - $form->content_model_type = 'optional'; |
|
147 | - $form->attr['target'] = 'FrameTarget'; |
|
144 | + $form = $this->addBlankElement('form'); |
|
145 | + $form->content_model = 'Flow | #PCDATA'; |
|
146 | + $form->content_model_type = 'optional'; |
|
147 | + $form->attr['target'] = 'FrameTarget'; |
|
148 | 148 | |
149 | - $input = $this->addBlankElement('input'); |
|
150 | - $input->attr['align'] = 'IAlign'; |
|
149 | + $input = $this->addBlankElement('input'); |
|
150 | + $input->attr['align'] = 'IAlign'; |
|
151 | 151 | |
152 | - $legend = $this->addBlankElement('legend'); |
|
153 | - $legend->attr['align'] = 'LAlign'; |
|
152 | + $legend = $this->addBlankElement('legend'); |
|
153 | + $legend->attr['align'] = 'LAlign'; |
|
154 | 154 | |
155 | - } |
|
155 | + } |
|
156 | 156 | |
157 | 157 | } |
158 | 158 |