@@ -13,7 +13,7 @@ |
||
13 | 13 | * @param string $aIP |
14 | 14 | * @param HTMLPurifier_Config $config |
15 | 15 | * @param HTMLPurifier_Context $context |
16 | - * @return bool|string |
|
16 | + * @return false|string |
|
17 | 17 | */ |
18 | 18 | public function validate($aIP, $config, $context) |
19 | 19 | { |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | $original = $aIP; |
25 | 25 | |
26 | 26 | $hex = '[0-9a-fA-F]'; |
27 | - $blk = '(?:' . $hex . '{1,4})'; |
|
27 | + $blk = '(?:'.$hex.'{1,4})'; |
|
28 | 28 | $pre = '(?:/(?:12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9]))'; // /0 - /128 |
29 | 29 | |
30 | 30 | // prefix check |
31 | 31 | if (strpos($aIP, '/') !== false) { |
32 | - if (preg_match('#' . $pre . '$#s', $aIP, $find)) { |
|
33 | - $aIP = substr($aIP, 0, 0 - strlen($find[0])); |
|
32 | + if (preg_match('#'.$pre.'$#s', $aIP, $find)) { |
|
33 | + $aIP = substr($aIP, 0, 0 - strlen($find[ 0 ])); |
|
34 | 34 | unset($find); |
35 | 35 | } else { |
36 | 36 | return false; |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | // IPv4-compatiblity check |
41 | - if (preg_match('#(?<=:' . ')' . $this->ip4 . '$#s', $aIP, $find)) { |
|
42 | - $aIP = substr($aIP, 0, 0 - strlen($find[0])); |
|
43 | - $ip = explode('.', $find[0]); |
|
41 | + if (preg_match('#(?<=:'.')'.$this->ip4.'$#s', $aIP, $find)) { |
|
42 | + $aIP = substr($aIP, 0, 0 - strlen($find[ 0 ])); |
|
43 | + $ip = explode('.', $find[ 0 ]); |
|
44 | 44 | $ip = array_map('dechex', $ip); |
45 | - $aIP .= $ip[0] . $ip[1] . ':' . $ip[2] . $ip[3]; |
|
45 | + $aIP .= $ip[ 0 ].$ip[ 1 ].':'.$ip[ 2 ].$ip[ 3 ]; |
|
46 | 46 | unset($find, $ip); |
47 | 47 | } |
48 | 48 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $aIP = $first; |
69 | 69 | unset($first, $second); |
70 | 70 | } else { |
71 | - $aIP = explode(':', $aIP[0]); |
|
71 | + $aIP = explode(':', $aIP[ 0 ]); |
|
72 | 72 | } |
73 | 73 | $c = count($aIP); |
74 | 74 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | private $_pcre_regex; |
32 | 32 | |
33 | 33 | /** |
34 | - * @param $dtd_regex Allowed child pattern from the DTD |
|
34 | + * @param string $dtd_regex Allowed child pattern from the DTD |
|
35 | 35 | */ |
36 | 36 | public function __construct($dtd_regex) |
37 | 37 | { |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | // collect all elements into the $elements array |
58 | 58 | preg_match_all("/$el/", $reg, $matches); |
59 | - foreach ($matches[0] as $match) { |
|
60 | - $this->elements[$match] = true; |
|
59 | + foreach ($matches[ 0 ] as $match) { |
|
60 | + $this->elements[ $match ] = true; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // setup all elements as parentheticals with leading commas |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | if (!empty($node->is_whitespace)) { |
87 | 87 | continue; |
88 | 88 | } |
89 | - $list_of_children .= $node->name . ','; |
|
89 | + $list_of_children .= $node->name.','; |
|
90 | 90 | } |
91 | 91 | // add leading comma to deal with stray comma declarations |
92 | - $list_of_children = ',' . rtrim($list_of_children, ','); |
|
92 | + $list_of_children = ','.rtrim($list_of_children, ','); |
|
93 | 93 | $okay = |
94 | 94 | preg_match( |
95 | - '/^,?' . $this->_pcre_regex . '$/', |
|
95 | + '/^,?'.$this->_pcre_regex.'$/', |
|
96 | 96 | $list_of_children |
97 | 97 | ); |
98 | - return (bool)$okay; |
|
98 | + return (bool) $okay; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | public $type = 'optional'; |
21 | 21 | |
22 | 22 | /** |
23 | - * @param array $children |
|
23 | + * @param HTMLPurifier_Node[] $children |
|
24 | 24 | * @param HTMLPurifier_Config $config |
25 | 25 | * @param HTMLPurifier_Context $context |
26 | 26 | * @return array |
@@ -763,7 +763,7 @@ |
||
763 | 763 | * @param bool $mq_fix Boolean whether or not to enable magic quotes fix |
764 | 764 | * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy |
765 | 765 | * |
766 | - * @return mixed |
|
766 | + * @return HTMLPurifier_Config |
|
767 | 767 | */ |
768 | 768 | public static function loadArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) |
769 | 769 | { |
@@ -782,8 +782,8 @@ |
||
782 | 782 | */ |
783 | 783 | public function mergeArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true) |
784 | 784 | { |
785 | - $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $this->def); |
|
786 | - $this->loadArray($ret); |
|
785 | + $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $this->def); |
|
786 | + $this->loadArray($ret); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -178,18 +178,18 @@ discard block |
||
178 | 178 | if (!$this->finalized) { |
179 | 179 | $this->autoFinalize(); |
180 | 180 | } |
181 | - if (!isset($this->def->info[$key])) { |
|
181 | + if (!isset($this->def->info[ $key ])) { |
|
182 | 182 | // can't add % due to SimpleTest bug |
183 | 183 | $this->triggerError( |
184 | - 'Cannot retrieve value of undefined directive ' . htmlspecialchars($key), |
|
184 | + 'Cannot retrieve value of undefined directive '.htmlspecialchars($key), |
|
185 | 185 | E_USER_WARNING |
186 | 186 | ); |
187 | 187 | return; |
188 | 188 | } |
189 | - if (isset($this->def->info[$key]->isAlias)) { |
|
190 | - $d = $this->def->info[$key]; |
|
189 | + if (isset($this->def->info[ $key ]->isAlias)) { |
|
190 | + $d = $this->def->info[ $key ]; |
|
191 | 191 | $this->triggerError( |
192 | - 'Cannot get value from aliased directive, use real name ' . $d->key, |
|
192 | + 'Cannot get value from aliased directive, use real name '.$d->key, |
|
193 | 193 | E_USER_ERROR |
194 | 194 | ); |
195 | 195 | return; |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | list($ns) = explode('.', $key); |
199 | 199 | if ($ns !== $this->lock) { |
200 | 200 | $this->triggerError( |
201 | - 'Cannot get value of namespace ' . $ns . ' when lock for ' . |
|
202 | - $this->lock . |
|
203 | - ' is active, this probably indicates a Definition setup method ' . |
|
201 | + 'Cannot get value of namespace '.$ns.' when lock for '. |
|
202 | + $this->lock. |
|
203 | + ' is active, this probably indicates a Definition setup method '. |
|
204 | 204 | 'is accessing directives that are not within its namespace', |
205 | 205 | E_USER_ERROR |
206 | 206 | ); |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | $this->autoFinalize(); |
224 | 224 | } |
225 | 225 | $full = $this->getAll(); |
226 | - if (!isset($full[$namespace])) { |
|
226 | + if (!isset($full[ $namespace ])) { |
|
227 | 227 | $this->triggerError( |
228 | - 'Cannot retrieve undefined namespace ' . |
|
228 | + 'Cannot retrieve undefined namespace '. |
|
229 | 229 | htmlspecialchars($namespace), |
230 | 230 | E_USER_WARNING |
231 | 231 | ); |
232 | 232 | return; |
233 | 233 | } |
234 | - return $full[$namespace]; |
|
234 | + return $full[ $namespace ]; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function getBatchSerial($namespace) |
248 | 248 | { |
249 | - if (empty($this->serials[$namespace])) { |
|
249 | + if (empty($this->serials[ $namespace ])) { |
|
250 | 250 | $batch = $this->getBatch($namespace); |
251 | - unset($batch['DefinitionRev']); |
|
252 | - $this->serials[$namespace] = sha1(serialize($batch)); |
|
251 | + unset($batch[ 'DefinitionRev' ]); |
|
252 | + $this->serials[ $namespace ] = sha1(serialize($batch)); |
|
253 | 253 | } |
254 | - return $this->serials[$namespace]; |
|
254 | + return $this->serials[ $namespace ]; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $ret = array(); |
282 | 282 | foreach ($this->plist->squash() as $name => $value) { |
283 | 283 | list($ns, $key) = explode('.', $name, 2); |
284 | - $ret[$ns][$key] = $value; |
|
284 | + $ret[ $ns ][ $key ] = $value; |
|
285 | 285 | } |
286 | 286 | return $ret; |
287 | 287 | } |
@@ -307,20 +307,20 @@ discard block |
||
307 | 307 | if ($this->isFinalized('Cannot set directive after finalization')) { |
308 | 308 | return; |
309 | 309 | } |
310 | - if (!isset($this->def->info[$key])) { |
|
310 | + if (!isset($this->def->info[ $key ])) { |
|
311 | 311 | $this->triggerError( |
312 | - 'Cannot set undefined directive ' . htmlspecialchars($key) . ' to value', |
|
312 | + 'Cannot set undefined directive '.htmlspecialchars($key).' to value', |
|
313 | 313 | E_USER_WARNING |
314 | 314 | ); |
315 | 315 | return; |
316 | 316 | } |
317 | - $def = $this->def->info[$key]; |
|
317 | + $def = $this->def->info[ $key ]; |
|
318 | 318 | |
319 | 319 | if (isset($def->isAlias)) { |
320 | 320 | if ($this->aliasMode) { |
321 | 321 | $this->triggerError( |
322 | 322 | 'Double-aliases not allowed, please fix '. |
323 | - 'ConfigSchema bug with' . $key, |
|
323 | + 'ConfigSchema bug with'.$key, |
|
324 | 324 | E_USER_ERROR |
325 | 325 | ); |
326 | 326 | return; |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $value = $this->parser->parse($value, $type, $allow_null); |
348 | 348 | } catch (HTMLPurifier_VarParserException $e) { |
349 | 349 | $this->triggerError( |
350 | - 'Value for ' . $key . ' is of invalid type, should be ' . |
|
350 | + 'Value for '.$key.' is of invalid type, should be '. |
|
351 | 351 | HTMLPurifier_VarParser::getTypeName($type), |
352 | 352 | E_USER_WARNING |
353 | 353 | ); |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | } |
356 | 356 | if (is_string($value) && is_object($def)) { |
357 | 357 | // resolve value alias if defined |
358 | - if (isset($def->aliases[$value])) { |
|
359 | - $value = $def->aliases[$value]; |
|
358 | + if (isset($def->aliases[ $value ])) { |
|
359 | + $value = $def->aliases[ $value ]; |
|
360 | 360 | } |
361 | 361 | // check to see if the value is allowed |
362 | - if (isset($def->allowed) && !isset($def->allowed[$value])) { |
|
362 | + if (isset($def->allowed) && !isset($def->allowed[ $value ])) { |
|
363 | 363 | $this->triggerError( |
364 | - 'Value not supported, valid values are: ' . |
|
364 | + 'Value not supported, valid values are: '. |
|
365 | 365 | $this->_listify($def->allowed), |
366 | 366 | E_USER_WARNING |
367 | 367 | ); |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | // this is a very costly process, so it's discouraged |
375 | 375 | // with finalization |
376 | 376 | if ($namespace == 'HTML' || $namespace == 'CSS' || $namespace == 'URI') { |
377 | - $this->definitions[$namespace] = null; |
|
377 | + $this->definitions[ $namespace ] = null; |
|
378 | 378 | } |
379 | 379 | |
380 | - $this->serials[$namespace] = false; |
|
380 | + $this->serials[ $namespace ] = false; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | { |
392 | 392 | $list = array(); |
393 | 393 | foreach ($lookup as $name => $b) { |
394 | - $list[] = $name; |
|
394 | + $list[ ] = $name; |
|
395 | 395 | } |
396 | 396 | return implode(', ', $list); |
397 | 397 | } |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | // full definition |
489 | 489 | // --------------- |
490 | 490 | // check if definition is in memory |
491 | - if (!empty($this->definitions[$type])) { |
|
492 | - $def = $this->definitions[$type]; |
|
491 | + if (!empty($this->definitions[ $type ])) { |
|
492 | + $def = $this->definitions[ $type ]; |
|
493 | 493 | // check if the definition is setup |
494 | 494 | if ($def->setup) { |
495 | 495 | return $def; |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | $def = $cache->get($this); |
506 | 506 | if ($def) { |
507 | 507 | // definition in cache, save to memory and return it |
508 | - $this->definitions[$type] = $def; |
|
508 | + $this->definitions[ $type ] = $def; |
|
509 | 509 | return $def; |
510 | 510 | } |
511 | 511 | // initialize it |
@@ -524,28 +524,27 @@ discard block |
||
524 | 524 | // check preconditions |
525 | 525 | $def = null; |
526 | 526 | if ($optimized) { |
527 | - if (is_null($this->get($type . '.DefinitionID'))) { |
|
527 | + if (is_null($this->get($type.'.DefinitionID'))) { |
|
528 | 528 | // fatally error out if definition ID not set |
529 | 529 | throw new HTMLPurifier_Exception( |
530 | 530 | "Cannot retrieve raw version without specifying %$type.DefinitionID" |
531 | 531 | ); |
532 | 532 | } |
533 | 533 | } |
534 | - if (!empty($this->definitions[$type])) { |
|
535 | - $def = $this->definitions[$type]; |
|
534 | + if (!empty($this->definitions[ $type ])) { |
|
535 | + $def = $this->definitions[ $type ]; |
|
536 | 536 | if ($def->setup && !$optimized) { |
537 | 537 | $extra = $this->chatty ? |
538 | - " (try moving this code block earlier in your initialization)" : |
|
539 | - ""; |
|
538 | + " (try moving this code block earlier in your initialization)" : ""; |
|
540 | 539 | throw new HTMLPurifier_Exception( |
541 | - "Cannot retrieve raw definition after it has already been setup" . |
|
540 | + "Cannot retrieve raw definition after it has already been setup". |
|
542 | 541 | $extra |
543 | 542 | ); |
544 | 543 | } |
545 | 544 | if ($def->optimized === null) { |
546 | 545 | $extra = $this->chatty ? " (try flushing your cache)" : ""; |
547 | 546 | throw new HTMLPurifier_Exception( |
548 | - "Optimization status of definition is unknown" . $extra |
|
547 | + "Optimization status of definition is unknown".$extra |
|
549 | 548 | ); |
550 | 549 | } |
551 | 550 | if ($def->optimized !== $optimized) { |
@@ -554,7 +553,7 @@ discard block |
||
554 | 553 | " (this backtrace is for the first inconsistent call, which was for a $msg raw definition)" |
555 | 554 | : ""; |
556 | 555 | throw new HTMLPurifier_Exception( |
557 | - "Inconsistent use of optimized and unoptimized raw definition retrievals" . $extra |
|
556 | + "Inconsistent use of optimized and unoptimized raw definition retrievals".$extra |
|
558 | 557 | ); |
559 | 558 | } |
560 | 559 | } |
@@ -580,22 +579,22 @@ discard block |
||
580 | 579 | if ($def) { |
581 | 580 | // save the full definition for later, but don't |
582 | 581 | // return it yet |
583 | - $this->definitions[$type] = $def; |
|
582 | + $this->definitions[ $type ] = $def; |
|
584 | 583 | return null; |
585 | 584 | } |
586 | 585 | } |
587 | 586 | // check invariants for creation |
588 | 587 | if (!$optimized) { |
589 | - if (!is_null($this->get($type . '.DefinitionID'))) { |
|
588 | + if (!is_null($this->get($type.'.DefinitionID'))) { |
|
590 | 589 | if ($this->chatty) { |
591 | 590 | $this->triggerError( |
592 | - 'Due to a documentation error in previous version of HTML Purifier, your ' . |
|
593 | - 'definitions are not being cached. If this is OK, you can remove the ' . |
|
594 | - '%$type.DefinitionRev and %$type.DefinitionID declaration. Otherwise, ' . |
|
595 | - 'modify your code to use maybeGetRawDefinition, and test if the returned ' . |
|
596 | - 'value is null before making any edits (if it is null, that means that a ' . |
|
597 | - 'cached version is available, and no raw operations are necessary). See ' . |
|
598 | - '<a href="http://htmlpurifier.org/docs/enduser-customize.html#optimized">' . |
|
591 | + 'Due to a documentation error in previous version of HTML Purifier, your '. |
|
592 | + 'definitions are not being cached. If this is OK, you can remove the '. |
|
593 | + '%$type.DefinitionRev and %$type.DefinitionID declaration. Otherwise, '. |
|
594 | + 'modify your code to use maybeGetRawDefinition, and test if the returned '. |
|
595 | + 'value is null before making any edits (if it is null, that means that a '. |
|
596 | + 'cached version is available, and no raw operations are necessary). See '. |
|
597 | + '<a href="http://htmlpurifier.org/docs/enduser-customize.html#optimized">'. |
|
599 | 598 | 'Customize</a> for more details', |
600 | 599 | E_USER_WARNING |
601 | 600 | ); |
@@ -637,7 +636,7 @@ discard block |
||
637 | 636 | "Definition of $type type not supported" |
638 | 637 | ); |
639 | 638 | } |
640 | - $this->definitions[$type] = $def; |
|
639 | + $this->definitions[ $type ] = $def; |
|
641 | 640 | return $def; |
642 | 641 | } |
643 | 642 | |
@@ -689,7 +688,7 @@ discard block |
||
689 | 688 | $namespace = $key; |
690 | 689 | $namespace_values = $value; |
691 | 690 | foreach ($namespace_values as $directive => $value2) { |
692 | - $this->set($namespace .'.'. $directive, $value2); |
|
691 | + $this->set($namespace.'.'.$directive, $value2); |
|
693 | 692 | } |
694 | 693 | } |
695 | 694 | } |
@@ -720,14 +719,14 @@ discard block |
||
720 | 719 | foreach ($allowed as $ns_or_directive) { |
721 | 720 | if (strpos($ns_or_directive, '.') !== false) { |
722 | 721 | // directive |
723 | - if ($ns_or_directive[0] == '-') { |
|
724 | - $blacklisted_directives[substr($ns_or_directive, 1)] = true; |
|
722 | + if ($ns_or_directive[ 0 ] == '-') { |
|
723 | + $blacklisted_directives[ substr($ns_or_directive, 1) ] = true; |
|
725 | 724 | } else { |
726 | - $allowed_directives[$ns_or_directive] = true; |
|
725 | + $allowed_directives[ $ns_or_directive ] = true; |
|
727 | 726 | } |
728 | 727 | } else { |
729 | 728 | // namespace |
730 | - $allowed_ns[$ns_or_directive] = true; |
|
729 | + $allowed_ns[ $ns_or_directive ] = true; |
|
731 | 730 | } |
732 | 731 | } |
733 | 732 | } |
@@ -735,10 +734,10 @@ discard block |
||
735 | 734 | foreach ($schema->info as $key => $def) { |
736 | 735 | list($ns, $directive) = explode('.', $key, 2); |
737 | 736 | if ($allowed !== true) { |
738 | - if (isset($blacklisted_directives["$ns.$directive"])) { |
|
737 | + if (isset($blacklisted_directives[ "$ns.$directive" ])) { |
|
739 | 738 | continue; |
740 | 739 | } |
741 | - if (!isset($allowed_directives["$ns.$directive"]) && !isset($allowed_ns[$ns])) { |
|
740 | + if (!isset($allowed_directives[ "$ns.$directive" ]) && !isset($allowed_ns[ $ns ])) { |
|
742 | 741 | continue; |
743 | 742 | } |
744 | 743 | } |
@@ -748,7 +747,7 @@ discard block |
||
748 | 747 | if ($directive == 'DefinitionID' || $directive == 'DefinitionRev') { |
749 | 748 | continue; |
750 | 749 | } |
751 | - $ret[] = array($ns, $directive); |
|
750 | + $ret[ ] = array($ns, $directive); |
|
752 | 751 | } |
753 | 752 | return $ret; |
754 | 753 | } |
@@ -801,7 +800,7 @@ discard block |
||
801 | 800 | public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) |
802 | 801 | { |
803 | 802 | if ($index !== false) { |
804 | - $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array(); |
|
803 | + $array = (isset($array[ $index ]) && is_array($array[ $index ])) ? $array[ $index ] : array(); |
|
805 | 804 | } |
806 | 805 | $mq = $mq_fix && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc(); |
807 | 806 | |
@@ -810,15 +809,15 @@ discard block |
||
810 | 809 | foreach ($allowed as $key) { |
811 | 810 | list($ns, $directive) = $key; |
812 | 811 | $skey = "$ns.$directive"; |
813 | - if (!empty($array["Null_$skey"])) { |
|
814 | - $ret[$ns][$directive] = null; |
|
812 | + if (!empty($array[ "Null_$skey" ])) { |
|
813 | + $ret[ $ns ][ $directive ] = null; |
|
815 | 814 | continue; |
816 | 815 | } |
817 | - if (!isset($array[$skey])) { |
|
816 | + if (!isset($array[ $skey ])) { |
|
818 | 817 | continue; |
819 | 818 | } |
820 | - $value = $mq ? stripslashes($array[$skey]) : $array[$skey]; |
|
821 | - $ret[$ns][$directive] = $value; |
|
819 | + $value = $mq ? stripslashes($array[ $skey ]) : $array[ $skey ]; |
|
820 | + $ret[ $ns ][ $directive ] = $value; |
|
822 | 821 | } |
823 | 822 | return $ret; |
824 | 823 | } |
@@ -890,15 +889,15 @@ discard block |
||
890 | 889 | // zip(tail(trace), trace) -- but PHP is not Haskell har har |
891 | 890 | for ($i = 0, $c = count($trace); $i < $c - 1; $i++) { |
892 | 891 | // XXX this is not correct on some versions of HTML Purifier |
893 | - if ($trace[$i + 1]['class'] === 'HTMLPurifier_Config') { |
|
892 | + if ($trace[ $i + 1 ][ 'class' ] === 'HTMLPurifier_Config') { |
|
894 | 893 | continue; |
895 | 894 | } |
896 | - $frame = $trace[$i]; |
|
897 | - $extra = " invoked on line {$frame['line']} in file {$frame['file']}"; |
|
895 | + $frame = $trace[ $i ]; |
|
896 | + $extra = " invoked on line {$frame[ 'line' ]} in file {$frame[ 'file' ]}"; |
|
898 | 897 | break; |
899 | 898 | } |
900 | 899 | } |
901 | - trigger_error($msg . $extra, $no); |
|
900 | + trigger_error($msg.$extra, $no); |
|
902 | 901 | } |
903 | 902 | |
904 | 903 | /** |
@@ -133,7 +133,9 @@ |
||
133 | 133 | } |
134 | 134 | if (is_string($config)) { |
135 | 135 | $ret->loadIni($config); |
136 | - } elseif (is_array($config)) $ret->loadArray($config); |
|
136 | + } elseif (is_array($config)) { |
|
137 | + $ret->loadArray($config); |
|
138 | + } |
|
137 | 139 | return $ret; |
138 | 140 | } |
139 | 141 |
@@ -451,7 +451,7 @@ |
||
451 | 451 | * separate lists for processing. Format is element[attr1|attr2],element2... |
452 | 452 | * @warning Although it's largely drawn from TinyMCE's implementation, |
453 | 453 | * it is different, and you'll probably have to modify your lists |
454 | - * @param array $list String list to parse |
|
454 | + * @param string $list String list to parse |
|
455 | 455 | * @return array |
456 | 456 | * @todo Give this its own class, probably static interface |
457 | 457 | */ |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | public function addAttribute($element_name, $attr_name, $def) |
114 | 114 | { |
115 | 115 | $module = $this->getAnonymousModule(); |
116 | - if (!isset($module->info[$element_name])) { |
|
116 | + if (!isset($module->info[ $element_name ])) { |
|
117 | 117 | $element = $module->addBlankElement($element_name); |
118 | 118 | } else { |
119 | - $element = $module->info[$element_name]; |
|
119 | + $element = $module->info[ $element_name ]; |
|
120 | 120 | } |
121 | - $element->attr[$attr_name] = $def; |
|
121 | + $element->attr[ $attr_name ] = $def; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | |
199 | 199 | // cleanup some of the element definitions |
200 | 200 | foreach ($this->info as $k => $v) { |
201 | - unset($this->info[$k]->content_model); |
|
202 | - unset($this->info[$k]->content_model_type); |
|
201 | + unset($this->info[ $k ]->content_model); |
|
202 | + unset($this->info[ $k ]->content_model_type); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
@@ -223,30 +223,30 @@ discard block |
||
223 | 223 | foreach ($this->manager->modules as $module) { |
224 | 224 | foreach ($module->info_tag_transform as $k => $v) { |
225 | 225 | if ($v === false) { |
226 | - unset($this->info_tag_transform[$k]); |
|
226 | + unset($this->info_tag_transform[ $k ]); |
|
227 | 227 | } else { |
228 | - $this->info_tag_transform[$k] = $v; |
|
228 | + $this->info_tag_transform[ $k ] = $v; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | foreach ($module->info_attr_transform_pre as $k => $v) { |
232 | 232 | if ($v === false) { |
233 | - unset($this->info_attr_transform_pre[$k]); |
|
233 | + unset($this->info_attr_transform_pre[ $k ]); |
|
234 | 234 | } else { |
235 | - $this->info_attr_transform_pre[$k] = $v; |
|
235 | + $this->info_attr_transform_pre[ $k ] = $v; |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | foreach ($module->info_attr_transform_post as $k => $v) { |
239 | 239 | if ($v === false) { |
240 | - unset($this->info_attr_transform_post[$k]); |
|
240 | + unset($this->info_attr_transform_post[ $k ]); |
|
241 | 241 | } else { |
242 | - $this->info_attr_transform_post[$k] = $v; |
|
242 | + $this->info_attr_transform_post[ $k ] = $v; |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | foreach ($module->info_injector as $k => $v) { |
246 | 246 | if ($v === false) { |
247 | - unset($this->info_injector[$k]); |
|
247 | + unset($this->info_injector[ $k ]); |
|
248 | 248 | } else { |
249 | - $this->info_injector[$k] = $v; |
|
249 | + $this->info_injector[ $k ] = $v; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | protected function setupConfigStuff($config) |
262 | 262 | { |
263 | 263 | $block_wrapper = $config->get('HTML.BlockWrapper'); |
264 | - if (isset($this->info_content_sets['Block'][$block_wrapper])) { |
|
264 | + if (isset($this->info_content_sets[ 'Block' ][ $block_wrapper ])) { |
|
265 | 265 | $this->info_block_wrapper = $block_wrapper; |
266 | 266 | } else { |
267 | 267 | trigger_error( |
@@ -300,10 +300,10 @@ discard block |
||
300 | 300 | |
301 | 301 | if (is_array($allowed_elements)) { |
302 | 302 | foreach ($this->info as $name => $d) { |
303 | - if (!isset($allowed_elements[$name])) { |
|
304 | - unset($this->info[$name]); |
|
303 | + if (!isset($allowed_elements[ $name ])) { |
|
304 | + unset($this->info[ $name ]); |
|
305 | 305 | } |
306 | - unset($allowed_elements[$name]); |
|
306 | + unset($allowed_elements[ $name ]); |
|
307 | 307 | } |
308 | 308 | // emit errors |
309 | 309 | foreach ($allowed_elements as $element => $d) { |
@@ -323,15 +323,15 @@ discard block |
||
323 | 323 | $keys = array($attr, "*@$attr", "*.$attr"); |
324 | 324 | $delete = true; |
325 | 325 | foreach ($keys as $key) { |
326 | - if ($delete && isset($allowed_attributes[$key])) { |
|
326 | + if ($delete && isset($allowed_attributes[ $key ])) { |
|
327 | 327 | $delete = false; |
328 | 328 | } |
329 | - if (isset($allowed_attributes_mutable[$key])) { |
|
330 | - unset($allowed_attributes_mutable[$key]); |
|
329 | + if (isset($allowed_attributes_mutable[ $key ])) { |
|
330 | + unset($allowed_attributes_mutable[ $key ]); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | if ($delete) { |
334 | - unset($this->info_global_attr[$attr]); |
|
334 | + unset($this->info_global_attr[ $attr ]); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
@@ -340,22 +340,22 @@ discard block |
||
340 | 340 | $keys = array("$tag@$attr", $attr, "*@$attr", "$tag.$attr", "*.$attr"); |
341 | 341 | $delete = true; |
342 | 342 | foreach ($keys as $key) { |
343 | - if ($delete && isset($allowed_attributes[$key])) { |
|
343 | + if ($delete && isset($allowed_attributes[ $key ])) { |
|
344 | 344 | $delete = false; |
345 | 345 | } |
346 | - if (isset($allowed_attributes_mutable[$key])) { |
|
347 | - unset($allowed_attributes_mutable[$key]); |
|
346 | + if (isset($allowed_attributes_mutable[ $key ])) { |
|
347 | + unset($allowed_attributes_mutable[ $key ]); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | if ($delete) { |
351 | - if ($this->info[$tag]->attr[$attr]->required) { |
|
351 | + if ($this->info[ $tag ]->attr[ $attr ]->required) { |
|
352 | 352 | trigger_error( |
353 | - "Required attribute '$attr' in element '$tag' " . |
|
353 | + "Required attribute '$attr' in element '$tag' ". |
|
354 | 354 | "was not allowed, which means '$tag' will not be allowed either", |
355 | 355 | E_USER_WARNING |
356 | 356 | ); |
357 | 357 | } |
358 | - unset($this->info[$tag]->attr[$attr]); |
|
358 | + unset($this->info[ $tag ]->attr[ $attr ]); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | } |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | $c = count($bits); |
366 | 366 | switch ($c) { |
367 | 367 | case 2: |
368 | - if ($bits[0] !== '*') { |
|
369 | - $element = htmlspecialchars($bits[0]); |
|
370 | - $attribute = htmlspecialchars($bits[1]); |
|
371 | - if (!isset($this->info[$element])) { |
|
368 | + if ($bits[ 0 ] !== '*') { |
|
369 | + $element = htmlspecialchars($bits[ 0 ]); |
|
370 | + $attribute = htmlspecialchars($bits[ 1 ]); |
|
371 | + if (!isset($this->info[ $element ])) { |
|
372 | 372 | trigger_error( |
373 | - "Cannot allow attribute '$attribute' if element " . |
|
373 | + "Cannot allow attribute '$attribute' if element ". |
|
374 | 374 | "'$element' is not allowed/supported $support" |
375 | 375 | ); |
376 | 376 | } else { |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | } |
384 | 384 | // otherwise fall through |
385 | 385 | case 1: |
386 | - $attribute = htmlspecialchars($bits[0]); |
|
386 | + $attribute = htmlspecialchars($bits[ 0 ]); |
|
387 | 387 | trigger_error( |
388 | 388 | "Global attribute '$attribute' is not ". |
389 | 389 | "supported in any elements $support", |
@@ -400,21 +400,21 @@ discard block |
||
400 | 400 | $forbidden_attributes = $config->get('HTML.ForbiddenAttributes'); |
401 | 401 | |
402 | 402 | foreach ($this->info as $tag => $info) { |
403 | - if (isset($forbidden_elements[$tag])) { |
|
404 | - unset($this->info[$tag]); |
|
403 | + if (isset($forbidden_elements[ $tag ])) { |
|
404 | + unset($this->info[ $tag ]); |
|
405 | 405 | continue; |
406 | 406 | } |
407 | 407 | foreach ($info->attr as $attr => $x) { |
408 | - if (isset($forbidden_attributes["$tag@$attr"]) || |
|
409 | - isset($forbidden_attributes["*@$attr"]) || |
|
410 | - isset($forbidden_attributes[$attr]) |
|
408 | + if (isset($forbidden_attributes[ "$tag@$attr" ]) || |
|
409 | + isset($forbidden_attributes[ "*@$attr" ]) || |
|
410 | + isset($forbidden_attributes[ $attr ]) |
|
411 | 411 | ) { |
412 | - unset($this->info[$tag]->attr[$attr]); |
|
412 | + unset($this->info[ $tag ]->attr[ $attr ]); |
|
413 | 413 | continue; |
414 | - } elseif (isset($forbidden_attributes["$tag.$attr"])) { // this segment might get removed eventually |
|
414 | + } elseif (isset($forbidden_attributes[ "$tag.$attr" ])) { // this segment might get removed eventually |
|
415 | 415 | // $tag.$attr are not user supplied, so no worries! |
416 | 416 | trigger_error( |
417 | - "Error with $tag.$attr: tag.attr syntax not supported for " . |
|
417 | + "Error with $tag.$attr: tag.attr syntax not supported for ". |
|
418 | 418 | "HTML.ForbiddenAttributes; use tag@attr instead", |
419 | 419 | E_USER_WARNING |
420 | 420 | ); |
@@ -425,10 +425,10 @@ discard block |
||
425 | 425 | if (strlen($key) < 2) { |
426 | 426 | continue; |
427 | 427 | } |
428 | - if ($key[0] != '*') { |
|
428 | + if ($key[ 0 ] != '*') { |
|
429 | 429 | continue; |
430 | 430 | } |
431 | - if ($key[1] == '.') { |
|
431 | + if ($key[ 1 ] == '.') { |
|
432 | 432 | trigger_error( |
433 | 433 | "Error with $key: *.attr syntax not supported for HTML.ForbiddenAttributes; use attr instead", |
434 | 434 | E_USER_WARNING |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | if ($injector->checkNeeded($config) !== false) { |
442 | 442 | // remove injector that does not have it's required |
443 | 443 | // elements/attributes present, and is thus not needed. |
444 | - unset($this->info_injector[$i]); |
|
444 | + unset($this->info_injector[ $i ]); |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | list($element, $attr) = explode('[', $chunk); |
476 | 476 | } |
477 | 477 | if ($element !== '*') { |
478 | - $elements[$element] = true; |
|
478 | + $elements[ $element ] = true; |
|
479 | 479 | } |
480 | 480 | if (!$attr) { |
481 | 481 | continue; |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | $attr = substr($attr, 0, strlen($attr) - 1); // remove trailing ] |
484 | 484 | $attr = explode('|', $attr); |
485 | 485 | foreach ($attr as $key) { |
486 | - $attributes["$element.$key"] = true; |
|
486 | + $attributes[ "$element.$key" ] = true; |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | return array($elements, $attributes); |
@@ -118,7 +118,7 @@ |
||
118 | 118 | * the HTMLPurifier_ElementDef class. There is a similar function |
119 | 119 | * in HTMLPurifier_HTMLDefinition. |
120 | 120 | * @param HTMLPurifier_ElementDef $def |
121 | - * @return HTMLPurifier_ChildDef subclass |
|
121 | + * @return boolean subclass |
|
122 | 122 | */ |
123 | 123 | public function getChildDef($def) |
124 | 124 | { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function addElement($element, $type, $contents, $attr_includes = array(), $attr = array()) |
145 | 145 | { |
146 | - $this->elements[] = $element; |
|
146 | + $this->elements[ ] = $element; |
|
147 | 147 | // parse content_model |
148 | 148 | list($content_model_type, $content_model) = $this->parseContents($contents); |
149 | 149 | // merge in attribute inclusions |
@@ -153,16 +153,16 @@ discard block |
||
153 | 153 | $this->addElementToContentSet($element, $type); |
154 | 154 | } |
155 | 155 | // create element |
156 | - $this->info[$element] = HTMLPurifier_ElementDef::create( |
|
156 | + $this->info[ $element ] = HTMLPurifier_ElementDef::create( |
|
157 | 157 | $content_model, |
158 | 158 | $content_model_type, |
159 | 159 | $attr |
160 | 160 | ); |
161 | 161 | // literal object $contents means direct child manipulation |
162 | 162 | if (!is_string($contents)) { |
163 | - $this->info[$element]->child = $contents; |
|
163 | + $this->info[ $element ]->child = $contents; |
|
164 | 164 | } |
165 | - return $this->info[$element]; |
|
165 | + return $this->info[ $element ]; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function addBlankElement($element) |
175 | 175 | { |
176 | - if (!isset($this->info[$element])) { |
|
177 | - $this->elements[] = $element; |
|
178 | - $this->info[$element] = new HTMLPurifier_ElementDef(); |
|
179 | - $this->info[$element]->standalone = false; |
|
176 | + if (!isset($this->info[ $element ])) { |
|
177 | + $this->elements[ ] = $element; |
|
178 | + $this->info[ $element ] = new HTMLPurifier_ElementDef(); |
|
179 | + $this->info[ $element ]->standalone = false; |
|
180 | 180 | } else { |
181 | 181 | trigger_error("Definition for $element already exists in module, cannot redefine"); |
182 | 182 | } |
183 | - return $this->info[$element]; |
|
183 | + return $this->info[ $element ]; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function addElementToContentSet($element, $type) |
193 | 193 | { |
194 | - if (!isset($this->content_sets[$type])) { |
|
195 | - $this->content_sets[$type] = ''; |
|
194 | + if (!isset($this->content_sets[ $type ])) { |
|
195 | + $this->content_sets[ $type ] = ''; |
|
196 | 196 | } else { |
197 | - $this->content_sets[$type] .= ' | '; |
|
197 | + $this->content_sets[ $type ] .= ' | '; |
|
198 | 198 | } |
199 | - $this->content_sets[$type] .= $element; |
|
199 | + $this->content_sets[ $type ] .= $element; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $attr_includes = array($attr_includes); |
245 | 245 | } |
246 | 246 | } |
247 | - $attr[0] = $attr_includes; |
|
247 | + $attr[ 0 ] = $attr_includes; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | if (is_null($value)) { |
266 | 266 | continue; |
267 | 267 | } |
268 | - $ret[$value] = true; |
|
268 | + $ret[ $value ] = true; |
|
269 | 269 | } |
270 | 270 | return $ret; |
271 | 271 | } |
@@ -205,6 +205,7 @@ |
||
205 | 205 | /** |
206 | 206 | * Adds a module to the current doctype by first registering it, |
207 | 207 | * and then tacking it on to the active doctype |
208 | + * @param HTMLPurifier_HTMLModule $module |
|
208 | 209 | */ |
209 | 210 | public function addModule($module) |
210 | 211 | { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $original_module = $module; |
175 | 175 | $ok = false; |
176 | 176 | foreach ($this->prefixes as $prefix) { |
177 | - $module = $prefix . $original_module; |
|
177 | + $module = $prefix.$original_module; |
|
178 | 178 | if (class_exists($module)) { |
179 | 179 | $ok = true; |
180 | 180 | break; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $module = $original_module; |
185 | 185 | if (!class_exists($module)) { |
186 | 186 | trigger_error( |
187 | - $original_module . ' module does not exist', |
|
187 | + $original_module.' module does not exist', |
|
188 | 188 | E_USER_ERROR |
189 | 189 | ); |
190 | 190 | return; |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | $module = new $module(); |
194 | 194 | } |
195 | 195 | if (empty($module->name)) { |
196 | - trigger_error('Module instance of ' . get_class($module) . ' must have name'); |
|
196 | + trigger_error('Module instance of '.get_class($module).' must have name'); |
|
197 | 197 | return; |
198 | 198 | } |
199 | - if (!$overload && isset($this->registeredModules[$module->name])) { |
|
200 | - trigger_error('Overloading ' . $module->name . ' without explicit overload parameter', E_USER_WARNING); |
|
199 | + if (!$overload && isset($this->registeredModules[ $module->name ])) { |
|
200 | + trigger_error('Overloading '.$module->name.' without explicit overload parameter', E_USER_WARNING); |
|
201 | 201 | } |
202 | - $this->registeredModules[$module->name] = $module; |
|
202 | + $this->registeredModules[ $module->name ] = $module; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | if (is_object($module)) { |
213 | 213 | $module = $module->name; |
214 | 214 | } |
215 | - $this->userModules[] = $module; |
|
215 | + $this->userModules[ ] = $module; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public function addPrefix($prefix) |
223 | 223 | { |
224 | - $this->prefixes[] = $prefix; |
|
224 | + $this->prefixes[ ] = $prefix; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -243,33 +243,33 @@ discard block |
||
243 | 243 | |
244 | 244 | if (is_array($lookup)) { |
245 | 245 | foreach ($modules as $k => $m) { |
246 | - if (isset($special_cases[$m])) { |
|
246 | + if (isset($special_cases[ $m ])) { |
|
247 | 247 | continue; |
248 | 248 | } |
249 | - if (!isset($lookup[$m])) { |
|
250 | - unset($modules[$k]); |
|
249 | + if (!isset($lookup[ $m ])) { |
|
250 | + unset($modules[ $k ]); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | // custom modules |
256 | 256 | if ($config->get('HTML.Proprietary')) { |
257 | - $modules[] = 'Proprietary'; |
|
257 | + $modules[ ] = 'Proprietary'; |
|
258 | 258 | } |
259 | 259 | if ($config->get('HTML.SafeObject')) { |
260 | - $modules[] = 'SafeObject'; |
|
260 | + $modules[ ] = 'SafeObject'; |
|
261 | 261 | } |
262 | 262 | if ($config->get('HTML.SafeEmbed')) { |
263 | - $modules[] = 'SafeEmbed'; |
|
263 | + $modules[ ] = 'SafeEmbed'; |
|
264 | 264 | } |
265 | 265 | if ($config->get('HTML.SafeScripting') !== array()) { |
266 | - $modules[] = 'SafeScripting'; |
|
266 | + $modules[ ] = 'SafeScripting'; |
|
267 | 267 | } |
268 | 268 | if ($config->get('HTML.Nofollow')) { |
269 | - $modules[] = 'Nofollow'; |
|
269 | + $modules[ ] = 'Nofollow'; |
|
270 | 270 | } |
271 | 271 | if ($config->get('HTML.TargetBlank')) { |
272 | - $modules[] = 'TargetBlank'; |
|
272 | + $modules[ ] = 'TargetBlank'; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | // merge in custom modules |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | |
278 | 278 | foreach ($modules as $module) { |
279 | 279 | $this->processModule($module); |
280 | - $this->modules[$module]->setup($config); |
|
280 | + $this->modules[ $module ]->setup($config); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | foreach ($this->doctype->tidyModules as $module) { |
284 | 284 | $this->processModule($module); |
285 | - $this->modules[$module]->setup($config); |
|
285 | + $this->modules[ $module ]->setup($config); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | // prepare any injectors |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $class = "HTMLPurifier_Injector_$injector"; |
294 | 294 | $injector = new $class; |
295 | 295 | } |
296 | - $n[$injector->name] = $injector; |
|
296 | + $n[ $injector->name ] = $injector; |
|
297 | 297 | } |
298 | 298 | $module->info_injector = $n; |
299 | 299 | } |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | // setup lookup table based on all valid modules |
302 | 302 | foreach ($this->modules as $module) { |
303 | 303 | foreach ($module->info as $name => $def) { |
304 | - if (!isset($this->elementLookup[$name])) { |
|
305 | - $this->elementLookup[$name] = array(); |
|
304 | + if (!isset($this->elementLookup[ $name ])) { |
|
305 | + $this->elementLookup[ $name ] = array(); |
|
306 | 306 | } |
307 | - $this->elementLookup[$name][] = $module->name; |
|
307 | + $this->elementLookup[ $name ][ ] = $module->name; |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public function processModule($module) |
331 | 331 | { |
332 | - if (!isset($this->registeredModules[$module]) || is_object($module)) { |
|
332 | + if (!isset($this->registeredModules[ $module ]) || is_object($module)) { |
|
333 | 333 | $this->registerModule($module); |
334 | 334 | } |
335 | - $this->modules[$module] = $this->registeredModules[$module]; |
|
335 | + $this->modules[ $module ] = $this->registeredModules[ $module ]; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | continue; |
348 | 348 | } |
349 | 349 | foreach ($module->info as $name => $v) { |
350 | - if (isset($elements[$name])) { |
|
350 | + if (isset($elements[ $name ])) { |
|
351 | 351 | continue; |
352 | 352 | } |
353 | - $elements[$name] = $this->getElement($name); |
|
353 | + $elements[ $name ] = $this->getElement($name); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | // appeared to be safe actually wasn't |
359 | 359 | foreach ($elements as $n => $v) { |
360 | 360 | if ($v === false) { |
361 | - unset($elements[$n]); |
|
361 | + unset($elements[ $n ]); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | */ |
379 | 379 | public function getElement($name, $trusted = null) |
380 | 380 | { |
381 | - if (!isset($this->elementLookup[$name])) { |
|
381 | + if (!isset($this->elementLookup[ $name ])) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | |
391 | 391 | // iterate through each module that has registered itself to this |
392 | 392 | // element |
393 | - foreach ($this->elementLookup[$name] as $module_name) { |
|
394 | - $module = $this->modules[$module_name]; |
|
393 | + foreach ($this->elementLookup[ $name ] as $module_name) { |
|
394 | + $module = $this->modules[ $module_name ]; |
|
395 | 395 | |
396 | 396 | // refuse to create/merge from a module that is deemed unsafe-- |
397 | 397 | // pretend the module doesn't exist--when trusted mode is not on. |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | // clone is used because, ideally speaking, the original |
403 | 403 | // definition should not be modified. Usually, this will |
404 | 404 | // make no difference, but for consistency's sake |
405 | - $new_def = clone $module->info[$name]; |
|
405 | + $new_def = clone $module->info[ $name ]; |
|
406 | 406 | |
407 | 407 | if (!$def && $new_def->standalone) { |
408 | 408 | $def = $new_def; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | // add information on required attributes |
450 | 450 | foreach ($def->attr as $attr_name => $attr_def) { |
451 | 451 | if ($attr_def->required) { |
452 | - $def->required_attr[] = $attr_name; |
|
452 | + $def->required_attr[ ] = $attr_name; |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | return $def; |
@@ -65,7 +65,7 @@ |
||
65 | 65 | * deleted a node, and now need to see if this change affected any |
66 | 66 | * earlier nodes. Rewinding does not affect other injectors, and can |
67 | 67 | * result in infinite loops if not used carefully. |
68 | - * @param bool|int $offset |
|
68 | + * @param integer $offset |
|
69 | 69 | * @warning HTML Purifier will prevent you from fast-forwarding with this |
70 | 70 | * function. |
71 | 71 | */ |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | if ($result !== false) { |
105 | 105 | return $result; |
106 | 106 | } |
107 | - $this->currentNesting =& $context->get('CurrentNesting'); |
|
108 | - $this->currentToken =& $context->get('CurrentToken'); |
|
109 | - $this->inputZipper =& $context->get('InputZipper'); |
|
107 | + $this->currentNesting = & $context->get('CurrentNesting'); |
|
108 | + $this->currentToken = & $context->get('CurrentToken'); |
|
109 | + $this->inputZipper = & $context->get('InputZipper'); |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | if (is_int($element)) { |
125 | 125 | $element = $attributes; |
126 | 126 | } |
127 | - if (!isset($def->info[$element])) { |
|
127 | + if (!isset($def->info[ $element ])) { |
|
128 | 128 | return $element; |
129 | 129 | } |
130 | 130 | if (!is_array($attributes)) { |
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | foreach ($attributes as $name) { |
134 | - if (!isset($def->info[$element]->attr[$name])) { |
|
134 | + if (!isset($def->info[ $element ]->attr[ $name ])) { |
|
135 | 135 | return "$element.$name"; |
136 | 136 | } |
137 | 137 | } |
@@ -148,19 +148,19 @@ discard block |
||
148 | 148 | { |
149 | 149 | if (!empty($this->currentNesting)) { |
150 | 150 | $parent_token = array_pop($this->currentNesting); |
151 | - $this->currentNesting[] = $parent_token; |
|
152 | - $parent = $this->htmlDefinition->info[$parent_token->name]; |
|
151 | + $this->currentNesting[ ] = $parent_token; |
|
152 | + $parent = $this->htmlDefinition->info[ $parent_token->name ]; |
|
153 | 153 | } else { |
154 | 154 | $parent = $this->htmlDefinition->info_parent_def; |
155 | 155 | } |
156 | - if (!isset($parent->child->elements[$name]) || isset($parent->excludes[$name])) { |
|
156 | + if (!isset($parent->child->elements[ $name ]) || isset($parent->excludes[ $name ])) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | // check for exclusion |
160 | 160 | for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) { |
161 | - $node = $this->currentNesting[$i]; |
|
162 | - $def = $this->htmlDefinition->info[$node->name]; |
|
163 | - if (isset($def->excludes[$name])) { |
|
161 | + $node = $this->currentNesting[ $i ]; |
|
162 | + $def = $this->htmlDefinition->info[ $node->name ]; |
|
163 | + if (isset($def->excludes[ $name ])) { |
|
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | if ($i < 0) { |
188 | 188 | return false; |
189 | 189 | } |
190 | - $current = $this->inputZipper->back[$i]; |
|
190 | + $current = $this->inputZipper->back[ $i ]; |
|
191 | 191 | return true; |
192 | 192 | } |
193 | 193 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | if ($i < 0) { |
242 | 242 | return false; |
243 | 243 | } |
244 | - $current = $this->inputZipper->front[$i]; |
|
244 | + $current = $this->inputZipper->front[ $i ]; |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 |
@@ -328,7 +328,7 @@ |
||
328 | 328 | * Determines if a particular token requires an earlier inline token |
329 | 329 | * to get a paragraph. This should be used with _forwardUntilEndToken |
330 | 330 | * @param HTMLPurifier_Token $current |
331 | - * @return bool |
|
331 | + * @return boolean|null |
|
332 | 332 | */ |
333 | 333 | private function _checkNeedsP($current) |
334 | 334 | { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | private function _pStart() |
25 | 25 | { |
26 | 26 | $par = new HTMLPurifier_Token_Start('p'); |
27 | - $par->armor['MakeWellFormed_TagClosedError'] = true; |
|
27 | + $par->armor[ 'MakeWellFormed_TagClosedError' ] = true; |
|
28 | 28 | return $par; |
29 | 29 | } |
30 | 30 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | // Is the current parent a <p> tag? |
90 | 90 | } elseif (!empty($this->currentNesting) && |
91 | - $this->currentNesting[count($this->currentNesting) - 1]->name == 'p') { |
|
91 | + $this->currentNesting[ count($this->currentNesting) - 1 ]->name == 'p') { |
|
92 | 92 | // State 3.1: ...<p>PAR1 |
93 | 93 | // ---- |
94 | 94 | |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | if ($c == 1) { |
221 | 221 | // There were no double-newlines, abort quickly. In theory this |
222 | 222 | // should never happen. |
223 | - $result[] = new HTMLPurifier_Token_Text($data); |
|
223 | + $result[ ] = new HTMLPurifier_Token_Text($data); |
|
224 | 224 | return; |
225 | 225 | } |
226 | 226 | for ($i = 0; $i < $c; $i++) { |
227 | - $par = $raw_paragraphs[$i]; |
|
227 | + $par = $raw_paragraphs[ $i ]; |
|
228 | 228 | if (trim($par) !== '') { |
229 | - $paragraphs[] = $par; |
|
229 | + $paragraphs[ ] = $par; |
|
230 | 230 | } else { |
231 | 231 | if ($i == 0) { |
232 | 232 | // Double newline at the front |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | // injector did not add any start paragraph tokens. |
236 | 236 | // This means that we have been in a paragraph for |
237 | 237 | // a while, and the newline means we should start a new one. |
238 | - $result[] = new HTMLPurifier_Token_End('p'); |
|
239 | - $result[] = new HTMLPurifier_Token_Text("\n\n"); |
|
238 | + $result[ ] = new HTMLPurifier_Token_End('p'); |
|
239 | + $result[ ] = new HTMLPurifier_Token_Text("\n\n"); |
|
240 | 240 | // However, the start token should only be added if |
241 | 241 | // there is more processing to be done (i.e. there are |
242 | 242 | // real paragraphs in here). If there are none, the |
@@ -265,15 +265,15 @@ discard block |
||
265 | 265 | |
266 | 266 | // Add the start tag indicated by \n\n at the beginning of $data |
267 | 267 | if ($needs_start) { |
268 | - $result[] = $this->_pStart(); |
|
268 | + $result[ ] = $this->_pStart(); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Append the paragraphs onto the result |
272 | 272 | foreach ($paragraphs as $par) { |
273 | - $result[] = new HTMLPurifier_Token_Text($par); |
|
274 | - $result[] = new HTMLPurifier_Token_End('p'); |
|
275 | - $result[] = new HTMLPurifier_Token_Text("\n\n"); |
|
276 | - $result[] = $this->_pStart(); |
|
273 | + $result[ ] = new HTMLPurifier_Token_Text($par); |
|
274 | + $result[ ] = new HTMLPurifier_Token_End('p'); |
|
275 | + $result[ ] = new HTMLPurifier_Token_Text("\n\n"); |
|
276 | + $result[ ] = $this->_pStart(); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // Remove trailing start token; Injector will handle this later if |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | */ |
298 | 298 | private function _isInline($token) |
299 | 299 | { |
300 | - return isset($this->htmlDefinition->info['p']->child->elements[$token->name]); |
|
300 | + return isset($this->htmlDefinition->info[ 'p' ]->child->elements[ $token->name ]); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |