@@ -48,7 +48,7 @@ |
||
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | $value = explode('!', $def->content_model); |
51 | - return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]); |
|
51 | + return new HTMLPurifier_ChildDef_Chameleon($value[ 0 ], $value[ 1 ]); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | // merge in the includes |
159 | 159 | // sorry, no way to override an include |
160 | 160 | foreach ($v as $v2) { |
161 | - $this->attr[0][] = $v2; |
|
161 | + $this->attr[ 0 ][ ] = $v2; |
|
162 | 162 | } |
163 | 163 | continue; |
164 | 164 | } |
165 | 165 | if ($v === false) { |
166 | - if (isset($this->attr[$k])) { |
|
167 | - unset($this->attr[$k]); |
|
166 | + if (isset($this->attr[ $k ])) { |
|
167 | + unset($this->attr[ $k ]); |
|
168 | 168 | } |
169 | 169 | continue; |
170 | 170 | } |
171 | - $this->attr[$k] = $v; |
|
171 | + $this->attr[ $k ] = $v; |
|
172 | 172 | } |
173 | 173 | $this->_mergeAssocArray($this->excludes, $def->excludes); |
174 | 174 | $this->attr_transform_pre = array_merge($this->attr_transform_pre, $def->attr_transform_pre); |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | { |
204 | 204 | foreach ($a2 as $k => $v) { |
205 | 205 | if ($v === false) { |
206 | - if (isset($a1[$k])) { |
|
207 | - unset($a1[$k]); |
|
206 | + if (isset($a1[ $k ])) { |
|
207 | + unset($a1[ $k ]); |
|
208 | 208 | } |
209 | 209 | continue; |
210 | 210 | } |
211 | - $a1[$k] = $v; |
|
211 | + $a1[ $k ] = $v; |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | } |
@@ -27,10 +27,10 @@ |
||
27 | 27 | */ |
28 | 28 | public function addDirective($directive) |
29 | 29 | { |
30 | - if (isset($this->directives[$i = $directive->id->toString()])) { |
|
30 | + if (isset($this->directives[ $i = $directive->id->toString() ])) { |
|
31 | 31 | throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'"); |
32 | 32 | } |
33 | - $this->directives[$i] = $directive; |
|
33 | + $this->directives[ $i ] = $directive; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $this->context = $context; |
34 | 34 | $this->obj = $obj; |
35 | 35 | $this->member = $member; |
36 | - $this->contents =& $obj->$member; |
|
36 | + $this->contents = & $obj->$member; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function error($msg) |
125 | 125 | { |
126 | - throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member) . ' in ' . $this->context . ' ' . $msg); |
|
126 | + throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member).' in '.$this->context.' '.$msg); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function validateId($id) |
67 | 67 | { |
68 | 68 | $id_string = $id->toString(); |
69 | - $this->context[] = "id '$id_string'"; |
|
69 | + $this->context[ ] = "id '$id_string'"; |
|
70 | 70 | if (!$id instanceof HTMLPurifier_ConfigSchema_Interchange_Id) { |
71 | 71 | // handled by InterchangeBuilder |
72 | 72 | $this->error(false, 'is not an instance of HTMLPurifier_ConfigSchema_Interchange_Id'); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function validateDirective($d) |
87 | 87 | { |
88 | 88 | $id = $d->id->toString(); |
89 | - $this->context[] = "directive '$id'"; |
|
89 | + $this->context[ ] = "directive '$id'"; |
|
90 | 90 | $this->validateId($d->id); |
91 | 91 | |
92 | 92 | $this->with($d, 'description') |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | // This also tests validity of $d->type |
102 | 102 | $this->parser->parse($d->default, $d->type, $d->typeAllowsNull); |
103 | 103 | } catch (HTMLPurifier_VarParserException $e) { |
104 | - $this->error('default', 'had error: ' . $e->getMessage()); |
|
104 | + $this->error('default', 'had error: '.$e->getMessage()); |
|
105 | 105 | } |
106 | 106 | // END - handled by InterchangeBuilder |
107 | 107 | |
108 | 108 | if (!is_null($d->allowed) || !empty($d->valueAliases)) { |
109 | 109 | // allowed and valueAliases require that we be dealing with |
110 | 110 | // strings, so check for that early. |
111 | - $d_int = HTMLPurifier_VarParser::$types[$d->type]; |
|
112 | - if (!isset(HTMLPurifier_VarParser::$stringTypes[$d_int])) { |
|
111 | + $d_int = HTMLPurifier_VarParser::$types[ $d->type ]; |
|
112 | + if (!isset(HTMLPurifier_VarParser::$stringTypes[ $d_int ])) { |
|
113 | 113 | $this->error('type', 'must be a string type when used with allowed or value aliases'); |
114 | 114 | } |
115 | 115 | } |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | $this->with($d, 'allowed') |
135 | 135 | ->assertNotEmpty() |
136 | 136 | ->assertIsLookup(); // handled by InterchangeBuilder |
137 | - if (is_string($d->default) && !isset($d->allowed[$d->default])) { |
|
137 | + if (is_string($d->default) && !isset($d->allowed[ $d->default ])) { |
|
138 | 138 | $this->error('default', 'must be an allowed value'); |
139 | 139 | } |
140 | - $this->context[] = 'allowed'; |
|
140 | + $this->context[ ] = 'allowed'; |
|
141 | 141 | foreach ($d->allowed as $val => $x) { |
142 | 142 | if (!is_string($val)) { |
143 | 143 | $this->error("value $val", 'must be a string'); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | $this->with($d, 'valueAliases') |
160 | 160 | ->assertIsArray(); // handled by InterchangeBuilder |
161 | - $this->context[] = 'valueAliases'; |
|
161 | + $this->context[ ] = 'valueAliases'; |
|
162 | 162 | foreach ($d->valueAliases as $alias => $real) { |
163 | 163 | if (!is_string($alias)) { |
164 | 164 | $this->error("alias $alias", 'must be a string'); |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | } |
173 | 173 | if (!is_null($d->allowed)) { |
174 | 174 | foreach ($d->valueAliases as $alias => $real) { |
175 | - if (isset($d->allowed[$alias])) { |
|
175 | + if (isset($d->allowed[ $alias ])) { |
|
176 | 176 | $this->error("alias '$alias'", 'must not be an allowed value'); |
177 | - } elseif (!isset($d->allowed[$real])) { |
|
177 | + } elseif (!isset($d->allowed[ $real ])) { |
|
178 | 178 | $this->error("alias '$alias'", 'must be an alias to an allowed value'); |
179 | 179 | } |
180 | 180 | } |
@@ -191,18 +191,18 @@ discard block |
||
191 | 191 | { |
192 | 192 | $this->with($d, 'aliases') |
193 | 193 | ->assertIsArray(); // handled by InterchangeBuilder |
194 | - $this->context[] = 'aliases'; |
|
194 | + $this->context[ ] = 'aliases'; |
|
195 | 195 | foreach ($d->aliases as $alias) { |
196 | 196 | $this->validateId($alias); |
197 | 197 | $s = $alias->toString(); |
198 | - if (isset($this->interchange->directives[$s])) { |
|
198 | + if (isset($this->interchange->directives[ $s ])) { |
|
199 | 199 | $this->error("alias '$s'", 'collides with another directive'); |
200 | 200 | } |
201 | - if (isset($this->aliases[$s])) { |
|
202 | - $other_directive = $this->aliases[$s]; |
|
201 | + if (isset($this->aliases[ $s ])) { |
|
202 | + $other_directive = $this->aliases[ $s ]; |
|
203 | 203 | $this->error("alias '$s'", "collides with alias for directive '$other_directive'"); |
204 | 204 | } |
205 | - $this->aliases[$s] = $d->id->toString(); |
|
205 | + $this->aliases[ $s ] = $d->id->toString(); |
|
206 | 206 | } |
207 | 207 | array_pop($this->context); |
208 | 208 | } |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | protected function error($target, $msg) |
229 | 229 | { |
230 | 230 | if ($target !== false) { |
231 | - $prefix = ucfirst($target) . ' in ' . $this->getFormattedContext(); |
|
231 | + $prefix = ucfirst($target).' in '.$this->getFormattedContext(); |
|
232 | 232 | } else { |
233 | 233 | $prefix = ucfirst($this->getFormattedContext()); |
234 | 234 | } |
235 | - throw new HTMLPurifier_ConfigSchema_Exception(trim($prefix . ' ' . $msg)); |
|
235 | + throw new HTMLPurifier_ConfigSchema_Exception(trim($prefix.' '.$msg)); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -36,26 +36,26 @@ discard block |
||
36 | 36 | public function buildDir($interchange, $dir = null) |
37 | 37 | { |
38 | 38 | if (!$dir) { |
39 | - $dir = HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema'; |
|
39 | + $dir = HTMLPURIFIER_PREFIX.'/HTMLPurifier/ConfigSchema/schema'; |
|
40 | 40 | } |
41 | - if (file_exists($dir . '/info.ini')) { |
|
42 | - $info = parse_ini_file($dir . '/info.ini'); |
|
43 | - $interchange->name = $info['name']; |
|
41 | + if (file_exists($dir.'/info.ini')) { |
|
42 | + $info = parse_ini_file($dir.'/info.ini'); |
|
43 | + $interchange->name = $info[ 'name' ]; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $files = array(); |
47 | 47 | $dh = opendir($dir); |
48 | 48 | while (false !== ($file = readdir($dh))) { |
49 | - if (!$file || $file[0] == '.' || strrchr($file, '.') !== '.txt') { |
|
49 | + if (!$file || $file[ 0 ] == '.' || strrchr($file, '.') !== '.txt') { |
|
50 | 50 | continue; |
51 | 51 | } |
52 | - $files[] = $file; |
|
52 | + $files[ ] = $file; |
|
53 | 53 | } |
54 | 54 | closedir($dh); |
55 | 55 | |
56 | 56 | sort($files); |
57 | 57 | foreach ($files as $file) { |
58 | - $this->buildFile($interchange, $dir . '/' . $file); |
|
58 | + $this->buildFile($interchange, $dir.'/'.$file); |
|
59 | 59 | } |
60 | 60 | return $interchange; |
61 | 61 | } |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | if (!$hash instanceof HTMLPurifier_StringHash) { |
85 | 85 | $hash = new HTMLPurifier_StringHash($hash); |
86 | 86 | } |
87 | - if (!isset($hash['ID'])) { |
|
87 | + if (!isset($hash[ 'ID' ])) { |
|
88 | 88 | throw new HTMLPurifier_ConfigSchema_Exception('Hash does not have any ID'); |
89 | 89 | } |
90 | - if (strpos($hash['ID'], '.') === false) { |
|
91 | - if (count($hash) == 2 && isset($hash['DESCRIPTION'])) { |
|
90 | + if (strpos($hash[ 'ID' ], '.') === false) { |
|
91 | + if (count($hash) == 2 && isset($hash[ 'DESCRIPTION' ])) { |
|
92 | 92 | $hash->offsetGet('DESCRIPTION'); // prevent complaining |
93 | 93 | } else { |
94 | 94 | throw new HTMLPurifier_ConfigSchema_Exception('All directives must have a namespace'); |
@@ -112,17 +112,17 @@ discard block |
||
112 | 112 | $directive->id = $this->id($hash->offsetGet('ID')); |
113 | 113 | $id = $directive->id->toString(); // convenience |
114 | 114 | |
115 | - if (isset($hash['TYPE'])) { |
|
115 | + if (isset($hash[ 'TYPE' ])) { |
|
116 | 116 | $type = explode('/', $hash->offsetGet('TYPE')); |
117 | - if (isset($type[1])) { |
|
117 | + if (isset($type[ 1 ])) { |
|
118 | 118 | $directive->typeAllowsNull = true; |
119 | 119 | } |
120 | - $directive->type = $type[0]; |
|
120 | + $directive->type = $type[ 0 ]; |
|
121 | 121 | } else { |
122 | 122 | throw new HTMLPurifier_ConfigSchema_Exception("TYPE in directive hash '$id' not defined"); |
123 | 123 | } |
124 | 124 | |
125 | - if (isset($hash['DEFAULT'])) { |
|
125 | + if (isset($hash[ 'DEFAULT' ])) { |
|
126 | 126 | try { |
127 | 127 | $directive->default = $this->varParser->parse( |
128 | 128 | $hash->offsetGet('DEFAULT'), |
@@ -130,43 +130,43 @@ discard block |
||
130 | 130 | $directive->typeAllowsNull |
131 | 131 | ); |
132 | 132 | } catch (HTMLPurifier_VarParserException $e) { |
133 | - throw new HTMLPurifier_ConfigSchema_Exception($e->getMessage() . " in DEFAULT in directive hash '$id'"); |
|
133 | + throw new HTMLPurifier_ConfigSchema_Exception($e->getMessage()." in DEFAULT in directive hash '$id'"); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if (isset($hash['DESCRIPTION'])) { |
|
137 | + if (isset($hash[ 'DESCRIPTION' ])) { |
|
138 | 138 | $directive->description = $hash->offsetGet('DESCRIPTION'); |
139 | 139 | } |
140 | 140 | |
141 | - if (isset($hash['ALLOWED'])) { |
|
141 | + if (isset($hash[ 'ALLOWED' ])) { |
|
142 | 142 | $directive->allowed = $this->lookup($this->evalArray($hash->offsetGet('ALLOWED'))); |
143 | 143 | } |
144 | 144 | |
145 | - if (isset($hash['VALUE-ALIASES'])) { |
|
145 | + if (isset($hash[ 'VALUE-ALIASES' ])) { |
|
146 | 146 | $directive->valueAliases = $this->evalArray($hash->offsetGet('VALUE-ALIASES')); |
147 | 147 | } |
148 | 148 | |
149 | - if (isset($hash['ALIASES'])) { |
|
149 | + if (isset($hash[ 'ALIASES' ])) { |
|
150 | 150 | $raw_aliases = trim($hash->offsetGet('ALIASES')); |
151 | 151 | $aliases = preg_split('/\s*,\s*/', $raw_aliases); |
152 | 152 | foreach ($aliases as $alias) { |
153 | - $directive->aliases[] = $this->id($alias); |
|
153 | + $directive->aliases[ ] = $this->id($alias); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - if (isset($hash['VERSION'])) { |
|
157 | + if (isset($hash[ 'VERSION' ])) { |
|
158 | 158 | $directive->version = $hash->offsetGet('VERSION'); |
159 | 159 | } |
160 | 160 | |
161 | - if (isset($hash['DEPRECATED-USE'])) { |
|
161 | + if (isset($hash[ 'DEPRECATED-USE' ])) { |
|
162 | 162 | $directive->deprecatedUse = $this->id($hash->offsetGet('DEPRECATED-USE')); |
163 | 163 | } |
164 | 164 | |
165 | - if (isset($hash['DEPRECATED-VERSION'])) { |
|
165 | + if (isset($hash[ 'DEPRECATED-VERSION' ])) { |
|
166 | 166 | $directive->deprecatedVersion = $hash->offsetGet('DEPRECATED-VERSION'); |
167 | 167 | } |
168 | 168 | |
169 | - if (isset($hash['EXTERNAL'])) { |
|
169 | + if (isset($hash[ 'EXTERNAL' ])) { |
|
170 | 170 | $directive->external = preg_split('/\s*,\s*/', trim($hash->offsetGet('EXTERNAL'))); |
171 | 171 | } |
172 | 172 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function evalArray($contents) |
181 | 181 | { |
182 | - return eval('return array(' . $contents . ');'); |
|
182 | + return eval('return array('.$contents.');'); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | { |
192 | 192 | $ret = array(); |
193 | 193 | foreach ($array as $val) { |
194 | - $ret[$val] = true; |
|
194 | + $ret[ $val ] = true; |
|
195 | 195 | } |
196 | 196 | return $ret; |
197 | 197 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | $accessed = $hash->getAccessed(); |
218 | 218 | foreach ($hash as $k => $v) { |
219 | - if (!isset($accessed[$k])) { |
|
219 | + if (!isset($accessed[ $k ])) { |
|
220 | 220 | trigger_error("String hash key '$k' not used by builder", E_USER_NOTICE); |
221 | 221 | } |
222 | 222 | } |
@@ -25,35 +25,35 @@ discard block |
||
25 | 25 | // definition wouldn't work. |
26 | 26 | |
27 | 27 | // pseudo-types, must be instantiated via shorthand |
28 | - $this->info['Enum'] = new HTMLPurifier_AttrDef_Enum(); |
|
29 | - $this->info['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool(); |
|
28 | + $this->info[ 'Enum' ] = new HTMLPurifier_AttrDef_Enum(); |
|
29 | + $this->info[ 'Bool' ] = new HTMLPurifier_AttrDef_HTML_Bool(); |
|
30 | 30 | |
31 | - $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text(); |
|
32 | - $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID(); |
|
33 | - $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length(); |
|
34 | - $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength(); |
|
35 | - $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens(); |
|
36 | - $this->info['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels(); |
|
37 | - $this->info['Text'] = new HTMLPurifier_AttrDef_Text(); |
|
38 | - $this->info['URI'] = new HTMLPurifier_AttrDef_URI(); |
|
39 | - $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang(); |
|
40 | - $this->info['Color'] = new HTMLPurifier_AttrDef_HTML_Color(); |
|
41 | - $this->info['IAlign'] = self::makeEnum('top,middle,bottom,left,right'); |
|
42 | - $this->info['LAlign'] = self::makeEnum('top,bottom,left,right'); |
|
43 | - $this->info['FrameTarget'] = new HTMLPurifier_AttrDef_HTML_FrameTarget(); |
|
31 | + $this->info[ 'CDATA' ] = new HTMLPurifier_AttrDef_Text(); |
|
32 | + $this->info[ 'ID' ] = new HTMLPurifier_AttrDef_HTML_ID(); |
|
33 | + $this->info[ 'Length' ] = new HTMLPurifier_AttrDef_HTML_Length(); |
|
34 | + $this->info[ 'MultiLength' ] = new HTMLPurifier_AttrDef_HTML_MultiLength(); |
|
35 | + $this->info[ 'NMTOKENS' ] = new HTMLPurifier_AttrDef_HTML_Nmtokens(); |
|
36 | + $this->info[ 'Pixels' ] = new HTMLPurifier_AttrDef_HTML_Pixels(); |
|
37 | + $this->info[ 'Text' ] = new HTMLPurifier_AttrDef_Text(); |
|
38 | + $this->info[ 'URI' ] = new HTMLPurifier_AttrDef_URI(); |
|
39 | + $this->info[ 'LanguageCode' ] = new HTMLPurifier_AttrDef_Lang(); |
|
40 | + $this->info[ 'Color' ] = new HTMLPurifier_AttrDef_HTML_Color(); |
|
41 | + $this->info[ 'IAlign' ] = self::makeEnum('top,middle,bottom,left,right'); |
|
42 | + $this->info[ 'LAlign' ] = self::makeEnum('top,bottom,left,right'); |
|
43 | + $this->info[ 'FrameTarget' ] = new HTMLPurifier_AttrDef_HTML_FrameTarget(); |
|
44 | 44 | |
45 | 45 | // unimplemented aliases |
46 | - $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text(); |
|
47 | - $this->info['ContentTypes'] = new HTMLPurifier_AttrDef_Text(); |
|
48 | - $this->info['Charsets'] = new HTMLPurifier_AttrDef_Text(); |
|
49 | - $this->info['Character'] = new HTMLPurifier_AttrDef_Text(); |
|
46 | + $this->info[ 'ContentType' ] = new HTMLPurifier_AttrDef_Text(); |
|
47 | + $this->info[ 'ContentTypes' ] = new HTMLPurifier_AttrDef_Text(); |
|
48 | + $this->info[ 'Charsets' ] = new HTMLPurifier_AttrDef_Text(); |
|
49 | + $this->info[ 'Character' ] = new HTMLPurifier_AttrDef_Text(); |
|
50 | 50 | |
51 | 51 | // "proprietary" types |
52 | - $this->info['Class'] = new HTMLPurifier_AttrDef_HTML_Class(); |
|
52 | + $this->info[ 'Class' ] = new HTMLPurifier_AttrDef_HTML_Class(); |
|
53 | 53 | |
54 | 54 | // number is really a positive integer (one or more digits) |
55 | 55 | // FIXME: ^^ not always, see start and value of list items |
56 | - $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true); |
|
56 | + $this->info[ 'Number' ] = new HTMLPurifier_AttrDef_Integer(false, false, true); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | private static function makeEnum($in) |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | $string = ''; |
76 | 76 | } |
77 | 77 | |
78 | - if (!isset($this->info[$type])) { |
|
79 | - trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR); |
|
78 | + if (!isset($this->info[ $type ])) { |
|
79 | + trigger_error('Cannot retrieve undefined attribute type '.$type, E_USER_ERROR); |
|
80 | 80 | return; |
81 | 81 | } |
82 | - return $this->info[$type]->make($string); |
|
82 | + return $this->info[ $type ]->make($string); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function set($type, $impl) |
91 | 91 | { |
92 | - $this->info[$type] = $impl; |
|
92 | + $this->info[ $type ] = $impl; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | public function validateToken($token, $config, $context) |
19 | 19 | { |
20 | 20 | $definition = $config->getHTMLDefinition(); |
21 | - $e =& $context->get('ErrorCollector', true); |
|
21 | + $e = & $context->get('ErrorCollector', true); |
|
22 | 22 | |
23 | 23 | // initialize IDAccumulator if necessary |
24 | - $ok =& $context->get('IDAccumulator', true); |
|
24 | + $ok = & $context->get('IDAccumulator', true); |
|
25 | 25 | if (!$ok) { |
26 | 26 | $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); |
27 | 27 | $context->register('IDAccumulator', $id_accumulator); |
28 | 28 | } |
29 | 29 | |
30 | 30 | // initialize CurrentToken if necessary |
31 | - $current_token =& $context->get('CurrentToken', true); |
|
31 | + $current_token = & $context->get('CurrentToken', true); |
|
32 | 32 | if (!$current_token) { |
33 | 33 | $context->register('CurrentToken', $token); |
34 | 34 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | // do local transformations only applicable to this element (pre) |
61 | 61 | // ex. <p align="right"> to <p style="text-align:right;"> |
62 | - foreach ($definition->info[$token->name]->attr_transform_pre as $transform) { |
|
62 | + foreach ($definition->info[ $token->name ]->attr_transform_pre as $transform) { |
|
63 | 63 | $attr = $transform->transform($o = $attr, $config, $context); |
64 | 64 | if ($e) { |
65 | 65 | if ($attr != $o) { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | // create alias to this element's attribute definition array, see |
72 | 72 | // also $d_defs (global attribute definition array) |
73 | 73 | // DEFINITION CALL |
74 | - $defs = $definition->info[$token->name]->attr; |
|
74 | + $defs = $definition->info[ $token->name ]->attr; |
|
75 | 75 | |
76 | 76 | $attr_key = false; |
77 | 77 | $context->register('CurrentAttr', $attr_key); |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | foreach ($attr as $attr_key => $value) { |
82 | 82 | |
83 | 83 | // call the definition |
84 | - if (isset($defs[$attr_key])) { |
|
84 | + if (isset($defs[ $attr_key ])) { |
|
85 | 85 | // there is a local definition defined |
86 | - if ($defs[$attr_key] === false) { |
|
86 | + if ($defs[ $attr_key ] === false) { |
|
87 | 87 | // We've explicitly been told not to allow this element. |
88 | 88 | // This is usually when there's a global definition |
89 | 89 | // that must be overridden. |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | $result = false; |
93 | 93 | } else { |
94 | 94 | // validate according to the element's definition |
95 | - $result = $defs[$attr_key]->validate( |
|
95 | + $result = $defs[ $attr_key ]->validate( |
|
96 | 96 | $value, |
97 | 97 | $config, |
98 | 98 | $context |
99 | 99 | ); |
100 | 100 | } |
101 | - } elseif (isset($d_defs[$attr_key])) { |
|
101 | + } elseif (isset($d_defs[ $attr_key ])) { |
|
102 | 102 | // there is a global definition defined, validate according |
103 | 103 | // to the global definition |
104 | - $result = $d_defs[$attr_key]->validate( |
|
104 | + $result = $d_defs[ $attr_key ]->validate( |
|
105 | 105 | $value, |
106 | 106 | $config, |
107 | 107 | $context |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | // remove the attribute |
123 | - unset($attr[$attr_key]); |
|
123 | + unset($attr[ $attr_key ]); |
|
124 | 124 | } elseif (is_string($result)) { |
125 | 125 | // generally, if a substitution is happening, there |
126 | 126 | // was some sort of implicit correction going on. We'll |
127 | 127 | // delegate it to the attribute classes to say exactly what. |
128 | 128 | |
129 | 129 | // simple substitution |
130 | - $attr[$attr_key] = $result; |
|
130 | + $attr[ $attr_key ] = $result; |
|
131 | 131 | } else { |
132 | 132 | // nothing happens |
133 | 133 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // local (error reporting untested) |
157 | - foreach ($definition->info[$token->name]->attr_transform_post as $transform) { |
|
157 | + foreach ($definition->info[ $token->name ]->attr_transform_post as $transform) { |
|
158 | 158 | $attr = $transform->transform($o = $attr, $config, $context); |
159 | 159 | if ($e) { |
160 | 160 | if ($attr != $o) { |
@@ -25,23 +25,23 @@ discard block |
||
25 | 25 | { |
26 | 26 | // unreserved letters, ought to const-ify |
27 | 27 | for ($i = 48; $i <= 57; $i++) { // digits |
28 | - $this->preserve[$i] = true; |
|
28 | + $this->preserve[ $i ] = true; |
|
29 | 29 | } |
30 | 30 | for ($i = 65; $i <= 90; $i++) { // upper-case |
31 | - $this->preserve[$i] = true; |
|
31 | + $this->preserve[ $i ] = true; |
|
32 | 32 | } |
33 | 33 | for ($i = 97; $i <= 122; $i++) { // lower-case |
34 | - $this->preserve[$i] = true; |
|
34 | + $this->preserve[ $i ] = true; |
|
35 | 35 | } |
36 | - $this->preserve[45] = true; // Dash - |
|
37 | - $this->preserve[46] = true; // Period . |
|
38 | - $this->preserve[95] = true; // Underscore _ |
|
39 | - $this->preserve[126]= true; // Tilde ~ |
|
36 | + $this->preserve[ 45 ] = true; // Dash - |
|
37 | + $this->preserve[ 46 ] = true; // Period . |
|
38 | + $this->preserve[ 95 ] = true; // Underscore _ |
|
39 | + $this->preserve[ 126 ] = true; // Tilde ~ |
|
40 | 40 | |
41 | 41 | // extra letters not to escape |
42 | 42 | if ($preserve !== false) { |
43 | 43 | for ($i = 0, $c = strlen($preserve); $i < $c; $i++) { |
44 | - $this->preserve[ord($preserve[$i])] = true; |
|
44 | + $this->preserve[ ord($preserve[ $i ]) ] = true; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | { |
61 | 61 | $ret = ''; |
62 | 62 | for ($i = 0, $c = strlen($string); $i < $c; $i++) { |
63 | - if ($string[$i] !== '%' && !isset($this->preserve[$int = ord($string[$i])])) { |
|
64 | - $ret .= '%' . sprintf('%02X', $int); |
|
63 | + if ($string[ $i ] !== '%' && !isset($this->preserve[ $int = ord($string[ $i ]) ])) { |
|
64 | + $ret .= '%'.sprintf('%02X', $int); |
|
65 | 65 | } else { |
66 | - $ret .= $string[$i]; |
|
66 | + $ret .= $string[ $i ]; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | return $ret; |
@@ -87,22 +87,22 @@ discard block |
||
87 | 87 | foreach ($parts as $part) { |
88 | 88 | $length = strlen($part); |
89 | 89 | if ($length < 2) { |
90 | - $ret .= '%25' . $part; |
|
90 | + $ret .= '%25'.$part; |
|
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | $encoding = substr($part, 0, 2); |
94 | 94 | $text = substr($part, 2); |
95 | 95 | if (!ctype_xdigit($encoding)) { |
96 | - $ret .= '%25' . $part; |
|
96 | + $ret .= '%25'.$part; |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $int = hexdec($encoding); |
100 | - if (isset($this->preserve[$int])) { |
|
101 | - $ret .= chr($int) . $text; |
|
100 | + if (isset($this->preserve[ $int ])) { |
|
101 | + $ret .= chr($int).$text; |
|
102 | 102 | continue; |
103 | 103 | } |
104 | 104 | $encoding = strtoupper($encoding); |
105 | - $ret .= '%' . $encoding . $text; |
|
105 | + $ret .= '%'.$encoding.$text; |
|
106 | 106 | } |
107 | 107 | return $ret; |
108 | 108 | } |