@@ -6,30 +6,30 @@ |
||
6 | 6 | abstract class HTMLPurifier_TagTransform |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * Tag name to transform the tag to. |
|
11 | - */ |
|
12 | - public $transform_to; |
|
9 | + /** |
|
10 | + * Tag name to transform the tag to. |
|
11 | + */ |
|
12 | + public $transform_to; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Transforms the obsolete tag into the valid tag. |
|
16 | - * @param $tag Tag to be transformed. |
|
17 | - * @param $config Mandatory HTMLPurifier_Config object |
|
18 | - * @param $context Mandatory HTMLPurifier_Context object |
|
19 | - */ |
|
20 | - abstract public function transform($tag, $config, $context); |
|
14 | + /** |
|
15 | + * Transforms the obsolete tag into the valid tag. |
|
16 | + * @param $tag Tag to be transformed. |
|
17 | + * @param $config Mandatory HTMLPurifier_Config object |
|
18 | + * @param $context Mandatory HTMLPurifier_Context object |
|
19 | + */ |
|
20 | + abstract public function transform($tag, $config, $context); |
|
21 | 21 | |
22 | - /** |
|
23 | - * Prepends CSS properties to the style attribute, creating the |
|
24 | - * attribute if it doesn't exist. |
|
25 | - * @warning Copied over from AttrTransform, be sure to keep in sync |
|
26 | - * @param $attr Attribute array to process (passed by reference) |
|
27 | - * @param $css CSS to prepend |
|
28 | - */ |
|
29 | - protected function prependCSS(&$attr, $css) { |
|
30 | - $attr['style'] = isset($attr['style']) ? $attr['style'] : ''; |
|
31 | - $attr['style'] = $css . $attr['style']; |
|
32 | - } |
|
22 | + /** |
|
23 | + * Prepends CSS properties to the style attribute, creating the |
|
24 | + * attribute if it doesn't exist. |
|
25 | + * @warning Copied over from AttrTransform, be sure to keep in sync |
|
26 | + * @param $attr Attribute array to process (passed by reference) |
|
27 | + * @param $css CSS to prepend |
|
28 | + */ |
|
29 | + protected function prependCSS(&$attr, $css) { |
|
30 | + $attr['style'] = isset($attr['style']) ? $attr['style'] : ''; |
|
31 | + $attr['style'] = $css . $attr['style']; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | } |
35 | 35 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | */ |
29 | 29 | protected function prependCSS(&$attr, $css) { |
30 | 30 | $attr['style'] = isset($attr['style']) ? $attr['style'] : ''; |
31 | - $attr['style'] = $css . $attr['style']; |
|
31 | + $attr['style'] = $css.$attr['style']; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | } |
@@ -18,81 +18,81 @@ |
||
18 | 18 | class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform |
19 | 19 | { |
20 | 20 | |
21 | - public $transform_to = 'span'; |
|
21 | + public $transform_to = 'span'; |
|
22 | 22 | |
23 | - protected $_size_lookup = array( |
|
24 | - '0' => 'xx-small', |
|
25 | - '1' => 'xx-small', |
|
26 | - '2' => 'small', |
|
27 | - '3' => 'medium', |
|
28 | - '4' => 'large', |
|
29 | - '5' => 'x-large', |
|
30 | - '6' => 'xx-large', |
|
31 | - '7' => '300%', |
|
32 | - '-1' => 'smaller', |
|
33 | - '-2' => '60%', |
|
34 | - '+1' => 'larger', |
|
35 | - '+2' => '150%', |
|
36 | - '+3' => '200%', |
|
37 | - '+4' => '300%' |
|
38 | - ); |
|
23 | + protected $_size_lookup = array( |
|
24 | + '0' => 'xx-small', |
|
25 | + '1' => 'xx-small', |
|
26 | + '2' => 'small', |
|
27 | + '3' => 'medium', |
|
28 | + '4' => 'large', |
|
29 | + '5' => 'x-large', |
|
30 | + '6' => 'xx-large', |
|
31 | + '7' => '300%', |
|
32 | + '-1' => 'smaller', |
|
33 | + '-2' => '60%', |
|
34 | + '+1' => 'larger', |
|
35 | + '+2' => '150%', |
|
36 | + '+3' => '200%', |
|
37 | + '+4' => '300%' |
|
38 | + ); |
|
39 | 39 | |
40 | - public function transform($tag, $config, $context) { |
|
40 | + public function transform($tag, $config, $context) { |
|
41 | 41 | |
42 | - if ($tag instanceof HTMLPurifier_Token_End) { |
|
43 | - $new_tag = clone $tag; |
|
44 | - $new_tag->name = $this->transform_to; |
|
45 | - return $new_tag; |
|
46 | - } |
|
42 | + if ($tag instanceof HTMLPurifier_Token_End) { |
|
43 | + $new_tag = clone $tag; |
|
44 | + $new_tag->name = $this->transform_to; |
|
45 | + return $new_tag; |
|
46 | + } |
|
47 | 47 | |
48 | - $attr = $tag->attr; |
|
49 | - $prepend_style = ''; |
|
48 | + $attr = $tag->attr; |
|
49 | + $prepend_style = ''; |
|
50 | 50 | |
51 | - // handle color transform |
|
52 | - if (isset($attr['color'])) { |
|
53 | - $prepend_style .= 'color:' . $attr['color'] . ';'; |
|
54 | - unset($attr['color']); |
|
55 | - } |
|
51 | + // handle color transform |
|
52 | + if (isset($attr['color'])) { |
|
53 | + $prepend_style .= 'color:' . $attr['color'] . ';'; |
|
54 | + unset($attr['color']); |
|
55 | + } |
|
56 | 56 | |
57 | - // handle face transform |
|
58 | - if (isset($attr['face'])) { |
|
59 | - $prepend_style .= 'font-family:' . $attr['face'] . ';'; |
|
60 | - unset($attr['face']); |
|
61 | - } |
|
57 | + // handle face transform |
|
58 | + if (isset($attr['face'])) { |
|
59 | + $prepend_style .= 'font-family:' . $attr['face'] . ';'; |
|
60 | + unset($attr['face']); |
|
61 | + } |
|
62 | 62 | |
63 | - // handle size transform |
|
64 | - if (isset($attr['size'])) { |
|
65 | - // normalize large numbers |
|
66 | - if ($attr['size'] !== '') { |
|
67 | - if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { |
|
68 | - $size = (int) $attr['size']; |
|
69 | - if ($size < -2) $attr['size'] = '-2'; |
|
70 | - if ($size > 4) $attr['size'] = '+4'; |
|
71 | - } else { |
|
72 | - $size = (int) $attr['size']; |
|
73 | - if ($size > 7) $attr['size'] = '7'; |
|
74 | - } |
|
75 | - } |
|
76 | - if (isset($this->_size_lookup[$attr['size']])) { |
|
77 | - $prepend_style .= 'font-size:' . |
|
78 | - $this->_size_lookup[$attr['size']] . ';'; |
|
79 | - } |
|
80 | - unset($attr['size']); |
|
81 | - } |
|
63 | + // handle size transform |
|
64 | + if (isset($attr['size'])) { |
|
65 | + // normalize large numbers |
|
66 | + if ($attr['size'] !== '') { |
|
67 | + if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { |
|
68 | + $size = (int) $attr['size']; |
|
69 | + if ($size < -2) $attr['size'] = '-2'; |
|
70 | + if ($size > 4) $attr['size'] = '+4'; |
|
71 | + } else { |
|
72 | + $size = (int) $attr['size']; |
|
73 | + if ($size > 7) $attr['size'] = '7'; |
|
74 | + } |
|
75 | + } |
|
76 | + if (isset($this->_size_lookup[$attr['size']])) { |
|
77 | + $prepend_style .= 'font-size:' . |
|
78 | + $this->_size_lookup[$attr['size']] . ';'; |
|
79 | + } |
|
80 | + unset($attr['size']); |
|
81 | + } |
|
82 | 82 | |
83 | - if ($prepend_style) { |
|
84 | - $attr['style'] = isset($attr['style']) ? |
|
85 | - $prepend_style . $attr['style'] : |
|
86 | - $prepend_style; |
|
87 | - } |
|
83 | + if ($prepend_style) { |
|
84 | + $attr['style'] = isset($attr['style']) ? |
|
85 | + $prepend_style . $attr['style'] : |
|
86 | + $prepend_style; |
|
87 | + } |
|
88 | 88 | |
89 | - $new_tag = clone $tag; |
|
90 | - $new_tag->name = $this->transform_to; |
|
91 | - $new_tag->attr = $attr; |
|
89 | + $new_tag = clone $tag; |
|
90 | + $new_tag->name = $this->transform_to; |
|
91 | + $new_tag->attr = $attr; |
|
92 | 92 | |
93 | - return $new_tag; |
|
93 | + return $new_tag; |
|
94 | 94 | |
95 | - } |
|
95 | + } |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // vim: et sw=4 sts=4 |
@@ -66,11 +66,17 @@ |
||
66 | 66 | if ($attr['size'] !== '') { |
67 | 67 | if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { |
68 | 68 | $size = (int) $attr['size']; |
69 | - if ($size < -2) $attr['size'] = '-2'; |
|
70 | - if ($size > 4) $attr['size'] = '+4'; |
|
69 | + if ($size < -2) { |
|
70 | + $attr['size'] = '-2'; |
|
71 | + } |
|
72 | + if ($size > 4) { |
|
73 | + $attr['size'] = '+4'; |
|
74 | + } |
|
71 | 75 | } else { |
72 | 76 | $size = (int) $attr['size']; |
73 | - if ($size > 7) $attr['size'] = '7'; |
|
77 | + if ($size > 7) { |
|
78 | + $attr['size'] = '7'; |
|
79 | + } |
|
74 | 80 | } |
75 | 81 | } |
76 | 82 | if (isset($this->_size_lookup[$attr['size']])) { |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | |
51 | 51 | // handle color transform |
52 | 52 | if (isset($attr['color'])) { |
53 | - $prepend_style .= 'color:' . $attr['color'] . ';'; |
|
53 | + $prepend_style .= 'color:'.$attr['color'].';'; |
|
54 | 54 | unset($attr['color']); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // handle face transform |
58 | 58 | if (isset($attr['face'])) { |
59 | - $prepend_style .= 'font-family:' . $attr['face'] . ';'; |
|
59 | + $prepend_style .= 'font-family:'.$attr['face'].';'; |
|
60 | 60 | unset($attr['face']); |
61 | 61 | } |
62 | 62 | |
@@ -74,16 +74,15 @@ discard block |
||
74 | 74 | } |
75 | 75 | } |
76 | 76 | if (isset($this->_size_lookup[$attr['size']])) { |
77 | - $prepend_style .= 'font-size:' . |
|
78 | - $this->_size_lookup[$attr['size']] . ';'; |
|
77 | + $prepend_style .= 'font-size:'. |
|
78 | + $this->_size_lookup[$attr['size']].';'; |
|
79 | 79 | } |
80 | 80 | unset($attr['size']); |
81 | 81 | } |
82 | 82 | |
83 | 83 | if ($prepend_style) { |
84 | 84 | $attr['style'] = isset($attr['style']) ? |
85 | - $prepend_style . $attr['style'] : |
|
86 | - $prepend_style; |
|
85 | + $prepend_style.$attr['style'] : $prepend_style; |
|
87 | 86 | } |
88 | 87 | |
89 | 88 | $new_tag = clone $tag; |
@@ -8,27 +8,27 @@ |
||
8 | 8 | class HTMLPurifier_TagTransform_Simple extends HTMLPurifier_TagTransform |
9 | 9 | { |
10 | 10 | |
11 | - protected $style; |
|
11 | + protected $style; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @param $transform_to Tag name to transform to. |
|
15 | - * @param $style CSS style to add to the tag |
|
16 | - */ |
|
17 | - public function __construct($transform_to, $style = null) { |
|
18 | - $this->transform_to = $transform_to; |
|
19 | - $this->style = $style; |
|
20 | - } |
|
13 | + /** |
|
14 | + * @param $transform_to Tag name to transform to. |
|
15 | + * @param $style CSS style to add to the tag |
|
16 | + */ |
|
17 | + public function __construct($transform_to, $style = null) { |
|
18 | + $this->transform_to = $transform_to; |
|
19 | + $this->style = $style; |
|
20 | + } |
|
21 | 21 | |
22 | - public function transform($tag, $config, $context) { |
|
23 | - $new_tag = clone $tag; |
|
24 | - $new_tag->name = $this->transform_to; |
|
25 | - if (!is_null($this->style) && |
|
26 | - ($new_tag instanceof HTMLPurifier_Token_Start || $new_tag instanceof HTMLPurifier_Token_Empty) |
|
27 | - ) { |
|
28 | - $this->prependCSS($new_tag->attr, $this->style); |
|
29 | - } |
|
30 | - return $new_tag; |
|
31 | - } |
|
22 | + public function transform($tag, $config, $context) { |
|
23 | + $new_tag = clone $tag; |
|
24 | + $new_tag->name = $this->transform_to; |
|
25 | + if (!is_null($this->style) && |
|
26 | + ($new_tag instanceof HTMLPurifier_Token_Start || $new_tag instanceof HTMLPurifier_Token_Empty) |
|
27 | + ) { |
|
28 | + $this->prependCSS($new_tag->attr, $this->style); |
|
29 | + } |
|
30 | + return $new_tag; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | } |
34 | 34 |
@@ -4,53 +4,53 @@ |
||
4 | 4 | * Abstract base token class that all others inherit from. |
5 | 5 | */ |
6 | 6 | class HTMLPurifier_Token { |
7 | - public $line; /**< Line number node was on in source document. Null if unknown. */ |
|
8 | - public $col; /**< Column of line node was on in source document. Null if unknown. */ |
|
9 | - |
|
10 | - /** |
|
11 | - * Lookup array of processing that this token is exempt from. |
|
12 | - * Currently, valid values are "ValidateAttributes" and |
|
13 | - * "MakeWellFormed_TagClosedError" |
|
14 | - */ |
|
15 | - public $armor = array(); |
|
16 | - |
|
17 | - /** |
|
18 | - * Used during MakeWellFormed. |
|
19 | - */ |
|
20 | - public $skip; |
|
21 | - public $rewind; |
|
22 | - public $carryover; |
|
23 | - |
|
24 | - public function __get($n) { |
|
25 | - if ($n === 'type') { |
|
26 | - trigger_error('Deprecated type property called; use instanceof', E_USER_NOTICE); |
|
27 | - switch (get_class($this)) { |
|
28 | - case 'HTMLPurifier_Token_Start': return 'start'; |
|
29 | - case 'HTMLPurifier_Token_Empty': return 'empty'; |
|
30 | - case 'HTMLPurifier_Token_End': return 'end'; |
|
31 | - case 'HTMLPurifier_Token_Text': return 'text'; |
|
32 | - case 'HTMLPurifier_Token_Comment': return 'comment'; |
|
33 | - default: return null; |
|
34 | - } |
|
35 | - } |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * Sets the position of the token in the source document. |
|
40 | - */ |
|
41 | - public function position($l = null, $c = null) { |
|
42 | - $this->line = $l; |
|
43 | - $this->col = $c; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Convenience function for DirectLex settings line/col position. |
|
48 | - */ |
|
49 | - public function rawPosition($l, $c) { |
|
50 | - if ($c === -1) $l++; |
|
51 | - $this->line = $l; |
|
52 | - $this->col = $c; |
|
53 | - } |
|
7 | + public $line; /**< Line number node was on in source document. Null if unknown. */ |
|
8 | + public $col; /**< Column of line node was on in source document. Null if unknown. */ |
|
9 | + |
|
10 | + /** |
|
11 | + * Lookup array of processing that this token is exempt from. |
|
12 | + * Currently, valid values are "ValidateAttributes" and |
|
13 | + * "MakeWellFormed_TagClosedError" |
|
14 | + */ |
|
15 | + public $armor = array(); |
|
16 | + |
|
17 | + /** |
|
18 | + * Used during MakeWellFormed. |
|
19 | + */ |
|
20 | + public $skip; |
|
21 | + public $rewind; |
|
22 | + public $carryover; |
|
23 | + |
|
24 | + public function __get($n) { |
|
25 | + if ($n === 'type') { |
|
26 | + trigger_error('Deprecated type property called; use instanceof', E_USER_NOTICE); |
|
27 | + switch (get_class($this)) { |
|
28 | + case 'HTMLPurifier_Token_Start': return 'start'; |
|
29 | + case 'HTMLPurifier_Token_Empty': return 'empty'; |
|
30 | + case 'HTMLPurifier_Token_End': return 'end'; |
|
31 | + case 'HTMLPurifier_Token_Text': return 'text'; |
|
32 | + case 'HTMLPurifier_Token_Comment': return 'comment'; |
|
33 | + default: return null; |
|
34 | + } |
|
35 | + } |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * Sets the position of the token in the source document. |
|
40 | + */ |
|
41 | + public function position($l = null, $c = null) { |
|
42 | + $this->line = $l; |
|
43 | + $this->col = $c; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Convenience function for DirectLex settings line/col position. |
|
48 | + */ |
|
49 | + public function rawPosition($l, $c) { |
|
50 | + if ($c === -1) $l++; |
|
51 | + $this->line = $l; |
|
52 | + $this->col = $c; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
56 | 56 |
@@ -5,7 +5,7 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_Token { |
7 | 7 | public $line; /**< Line number node was on in source document. Null if unknown. */ |
8 | - public $col; /**< Column of line node was on in source document. Null if unknown. */ |
|
8 | + public $col; /**< Column of line node was on in source document. Null if unknown. */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Lookup array of processing that this token is exempt from. |
@@ -47,7 +47,9 @@ |
||
47 | 47 | * Convenience function for DirectLex settings line/col position. |
48 | 48 | */ |
49 | 49 | public function rawPosition($l, $c) { |
50 | - if ($c === -1) $l++; |
|
50 | + if ($c === -1) { |
|
51 | + $l++; |
|
52 | + } |
|
51 | 53 | $this->line = $l; |
52 | 54 | $this->col = $c; |
53 | 55 | } |
@@ -5,18 +5,18 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_Token_Comment extends HTMLPurifier_Token |
7 | 7 | { |
8 | - public $data; /**< Character data within comment. */ |
|
9 | - public $is_whitespace = true; |
|
10 | - /** |
|
11 | - * Transparent constructor. |
|
12 | - * |
|
13 | - * @param $data String comment data. |
|
14 | - */ |
|
15 | - public function __construct($data, $line = null, $col = null) { |
|
16 | - $this->data = $data; |
|
17 | - $this->line = $line; |
|
18 | - $this->col = $col; |
|
19 | - } |
|
8 | + public $data; /**< Character data within comment. */ |
|
9 | + public $is_whitespace = true; |
|
10 | + /** |
|
11 | + * Transparent constructor. |
|
12 | + * |
|
13 | + * @param $data String comment data. |
|
14 | + */ |
|
15 | + public function __construct($data, $line = null, $col = null) { |
|
16 | + $this->data = $data; |
|
17 | + $this->line = $line; |
|
18 | + $this->col = $col; |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | // vim: et sw=4 sts=4 |
@@ -9,11 +9,11 @@ |
||
9 | 9 | */ |
10 | 10 | class HTMLPurifier_Token_End extends HTMLPurifier_Token_Tag |
11 | 11 | { |
12 | - /** |
|
13 | - * Token that started this node. Added by MakeWellFormed. Please |
|
14 | - * do not edit this! |
|
15 | - */ |
|
16 | - public $start; |
|
12 | + /** |
|
13 | + * Token that started this node. Added by MakeWellFormed. Please |
|
14 | + * do not edit this! |
|
15 | + */ |
|
16 | + public $start; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | // vim: et sw=4 sts=4 |
@@ -5,53 +5,53 @@ |
||
5 | 5 | */ |
6 | 6 | class HTMLPurifier_Token_Tag extends HTMLPurifier_Token |
7 | 7 | { |
8 | - /** |
|
9 | - * Static bool marker that indicates the class is a tag. |
|
10 | - * |
|
11 | - * This allows us to check objects with <tt>!empty($obj->is_tag)</tt> |
|
12 | - * without having to use a function call <tt>is_a()</tt>. |
|
13 | - */ |
|
14 | - public $is_tag = true; |
|
8 | + /** |
|
9 | + * Static bool marker that indicates the class is a tag. |
|
10 | + * |
|
11 | + * This allows us to check objects with <tt>!empty($obj->is_tag)</tt> |
|
12 | + * without having to use a function call <tt>is_a()</tt>. |
|
13 | + */ |
|
14 | + public $is_tag = true; |
|
15 | 15 | |
16 | - /** |
|
17 | - * The lower-case name of the tag, like 'a', 'b' or 'blockquote'. |
|
18 | - * |
|
19 | - * @note Strictly speaking, XML tags are case sensitive, so we shouldn't |
|
20 | - * be lower-casing them, but these tokens cater to HTML tags, which are |
|
21 | - * insensitive. |
|
22 | - */ |
|
23 | - public $name; |
|
16 | + /** |
|
17 | + * The lower-case name of the tag, like 'a', 'b' or 'blockquote'. |
|
18 | + * |
|
19 | + * @note Strictly speaking, XML tags are case sensitive, so we shouldn't |
|
20 | + * be lower-casing them, but these tokens cater to HTML tags, which are |
|
21 | + * insensitive. |
|
22 | + */ |
|
23 | + public $name; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Associative array of the tag's attributes. |
|
27 | - */ |
|
28 | - public $attr = array(); |
|
25 | + /** |
|
26 | + * Associative array of the tag's attributes. |
|
27 | + */ |
|
28 | + public $attr = array(); |
|
29 | 29 | |
30 | - /** |
|
31 | - * Non-overloaded constructor, which lower-cases passed tag name. |
|
32 | - * |
|
33 | - * @param $name String name. |
|
34 | - * @param $attr Associative array of attributes. |
|
35 | - */ |
|
36 | - public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) { |
|
37 | - $this->name = ctype_lower($name) ? $name : strtolower($name); |
|
38 | - foreach ($attr as $key => $value) { |
|
39 | - // normalization only necessary when key is not lowercase |
|
40 | - if (!ctype_lower($key)) { |
|
41 | - $new_key = strtolower($key); |
|
42 | - if (!isset($attr[$new_key])) { |
|
43 | - $attr[$new_key] = $attr[$key]; |
|
44 | - } |
|
45 | - if ($new_key !== $key) { |
|
46 | - unset($attr[$key]); |
|
47 | - } |
|
48 | - } |
|
49 | - } |
|
50 | - $this->attr = $attr; |
|
51 | - $this->line = $line; |
|
52 | - $this->col = $col; |
|
53 | - $this->armor = $armor; |
|
54 | - } |
|
30 | + /** |
|
31 | + * Non-overloaded constructor, which lower-cases passed tag name. |
|
32 | + * |
|
33 | + * @param $name String name. |
|
34 | + * @param $attr Associative array of attributes. |
|
35 | + */ |
|
36 | + public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) { |
|
37 | + $this->name = ctype_lower($name) ? $name : strtolower($name); |
|
38 | + foreach ($attr as $key => $value) { |
|
39 | + // normalization only necessary when key is not lowercase |
|
40 | + if (!ctype_lower($key)) { |
|
41 | + $new_key = strtolower($key); |
|
42 | + if (!isset($attr[$new_key])) { |
|
43 | + $attr[$new_key] = $attr[$key]; |
|
44 | + } |
|
45 | + if ($new_key !== $key) { |
|
46 | + unset($attr[$key]); |
|
47 | + } |
|
48 | + } |
|
49 | + } |
|
50 | + $this->attr = $attr; |
|
51 | + $this->line = $line; |
|
52 | + $this->col = $col; |
|
53 | + $this->armor = $armor; |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // vim: et sw=4 sts=4 |
@@ -12,21 +12,21 @@ |
||
12 | 12 | class HTMLPurifier_Token_Text extends HTMLPurifier_Token |
13 | 13 | { |
14 | 14 | |
15 | - public $name = '#PCDATA'; /**< PCDATA tag name compatible with DTD. */ |
|
16 | - public $data; /**< Parsed character data of text. */ |
|
17 | - public $is_whitespace; /**< Bool indicating if node is whitespace. */ |
|
15 | + public $name = '#PCDATA'; /**< PCDATA tag name compatible with DTD. */ |
|
16 | + public $data; /**< Parsed character data of text. */ |
|
17 | + public $is_whitespace; /**< Bool indicating if node is whitespace. */ |
|
18 | 18 | |
19 | - /** |
|
20 | - * Constructor, accepts data and determines if it is whitespace. |
|
21 | - * |
|
22 | - * @param $data String parsed character data. |
|
23 | - */ |
|
24 | - public function __construct($data, $line = null, $col = null) { |
|
25 | - $this->data = $data; |
|
26 | - $this->is_whitespace = ctype_space($data); |
|
27 | - $this->line = $line; |
|
28 | - $this->col = $col; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Constructor, accepts data and determines if it is whitespace. |
|
21 | + * |
|
22 | + * @param $data String parsed character data. |
|
23 | + */ |
|
24 | + public function __construct($data, $line = null, $col = null) { |
|
25 | + $this->data = $data; |
|
26 | + $this->is_whitespace = ctype_space($data); |
|
27 | + $this->line = $line; |
|
28 | + $this->col = $col; |
|
29 | + } |
|
30 | 30 | |
31 | 31 | } |
32 | 32 |
@@ -14,80 +14,80 @@ |
||
14 | 14 | class HTMLPurifier_TokenFactory |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Prototypes that will be cloned. |
|
19 | - * @private |
|
20 | - */ |
|
21 | - // p stands for prototype |
|
22 | - private $p_start, $p_end, $p_empty, $p_text, $p_comment; |
|
17 | + /** |
|
18 | + * Prototypes that will be cloned. |
|
19 | + * @private |
|
20 | + */ |
|
21 | + // p stands for prototype |
|
22 | + private $p_start, $p_end, $p_empty, $p_text, $p_comment; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Generates blank prototypes for cloning. |
|
26 | - */ |
|
27 | - public function __construct() { |
|
28 | - $this->p_start = new HTMLPurifier_Token_Start('', array()); |
|
29 | - $this->p_end = new HTMLPurifier_Token_End(''); |
|
30 | - $this->p_empty = new HTMLPurifier_Token_Empty('', array()); |
|
31 | - $this->p_text = new HTMLPurifier_Token_Text(''); |
|
32 | - $this->p_comment= new HTMLPurifier_Token_Comment(''); |
|
33 | - } |
|
24 | + /** |
|
25 | + * Generates blank prototypes for cloning. |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | + $this->p_start = new HTMLPurifier_Token_Start('', array()); |
|
29 | + $this->p_end = new HTMLPurifier_Token_End(''); |
|
30 | + $this->p_empty = new HTMLPurifier_Token_Empty('', array()); |
|
31 | + $this->p_text = new HTMLPurifier_Token_Text(''); |
|
32 | + $this->p_comment= new HTMLPurifier_Token_Comment(''); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Creates a HTMLPurifier_Token_Start. |
|
37 | - * @param $name Tag name |
|
38 | - * @param $attr Associative array of attributes |
|
39 | - * @return Generated HTMLPurifier_Token_Start |
|
40 | - */ |
|
41 | - public function createStart($name, $attr = array()) { |
|
42 | - $p = clone $this->p_start; |
|
43 | - $p->__construct($name, $attr); |
|
44 | - return $p; |
|
45 | - } |
|
35 | + /** |
|
36 | + * Creates a HTMLPurifier_Token_Start. |
|
37 | + * @param $name Tag name |
|
38 | + * @param $attr Associative array of attributes |
|
39 | + * @return Generated HTMLPurifier_Token_Start |
|
40 | + */ |
|
41 | + public function createStart($name, $attr = array()) { |
|
42 | + $p = clone $this->p_start; |
|
43 | + $p->__construct($name, $attr); |
|
44 | + return $p; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Creates a HTMLPurifier_Token_End. |
|
49 | - * @param $name Tag name |
|
50 | - * @return Generated HTMLPurifier_Token_End |
|
51 | - */ |
|
52 | - public function createEnd($name) { |
|
53 | - $p = clone $this->p_end; |
|
54 | - $p->__construct($name); |
|
55 | - return $p; |
|
56 | - } |
|
47 | + /** |
|
48 | + * Creates a HTMLPurifier_Token_End. |
|
49 | + * @param $name Tag name |
|
50 | + * @return Generated HTMLPurifier_Token_End |
|
51 | + */ |
|
52 | + public function createEnd($name) { |
|
53 | + $p = clone $this->p_end; |
|
54 | + $p->__construct($name); |
|
55 | + return $p; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Creates a HTMLPurifier_Token_Empty. |
|
60 | - * @param $name Tag name |
|
61 | - * @param $attr Associative array of attributes |
|
62 | - * @return Generated HTMLPurifier_Token_Empty |
|
63 | - */ |
|
64 | - public function createEmpty($name, $attr = array()) { |
|
65 | - $p = clone $this->p_empty; |
|
66 | - $p->__construct($name, $attr); |
|
67 | - return $p; |
|
68 | - } |
|
58 | + /** |
|
59 | + * Creates a HTMLPurifier_Token_Empty. |
|
60 | + * @param $name Tag name |
|
61 | + * @param $attr Associative array of attributes |
|
62 | + * @return Generated HTMLPurifier_Token_Empty |
|
63 | + */ |
|
64 | + public function createEmpty($name, $attr = array()) { |
|
65 | + $p = clone $this->p_empty; |
|
66 | + $p->__construct($name, $attr); |
|
67 | + return $p; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Creates a HTMLPurifier_Token_Text. |
|
72 | - * @param $data Data of text token |
|
73 | - * @return Generated HTMLPurifier_Token_Text |
|
74 | - */ |
|
75 | - public function createText($data) { |
|
76 | - $p = clone $this->p_text; |
|
77 | - $p->__construct($data); |
|
78 | - return $p; |
|
79 | - } |
|
70 | + /** |
|
71 | + * Creates a HTMLPurifier_Token_Text. |
|
72 | + * @param $data Data of text token |
|
73 | + * @return Generated HTMLPurifier_Token_Text |
|
74 | + */ |
|
75 | + public function createText($data) { |
|
76 | + $p = clone $this->p_text; |
|
77 | + $p->__construct($data); |
|
78 | + return $p; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Creates a HTMLPurifier_Token_Comment. |
|
83 | - * @param $data Data of comment token |
|
84 | - * @return Generated HTMLPurifier_Token_Comment |
|
85 | - */ |
|
86 | - public function createComment($data) { |
|
87 | - $p = clone $this->p_comment; |
|
88 | - $p->__construct($data); |
|
89 | - return $p; |
|
90 | - } |
|
81 | + /** |
|
82 | + * Creates a HTMLPurifier_Token_Comment. |
|
83 | + * @param $data Data of comment token |
|
84 | + * @return Generated HTMLPurifier_Token_Comment |
|
85 | + */ |
|
86 | + public function createComment($data) { |
|
87 | + $p = clone $this->p_comment; |
|
88 | + $p->__construct($data); |
|
89 | + return $p; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | } |
93 | 93 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | $this->p_end = new HTMLPurifier_Token_End(''); |
30 | 30 | $this->p_empty = new HTMLPurifier_Token_Empty('', array()); |
31 | 31 | $this->p_text = new HTMLPurifier_Token_Text(''); |
32 | - $this->p_comment= new HTMLPurifier_Token_Comment(''); |
|
32 | + $this->p_comment = new HTMLPurifier_Token_Comment(''); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |