@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | public function __construct($config) |
23 | 23 | { |
24 | 24 | $def = $config->getCSSDefinition(); |
25 | - $this->info['font-style'] = $def->info['font-style']; |
|
26 | - $this->info['font-variant'] = $def->info['font-variant']; |
|
27 | - $this->info['font-weight'] = $def->info['font-weight']; |
|
28 | - $this->info['font-size'] = $def->info['font-size']; |
|
29 | - $this->info['line-height'] = $def->info['line-height']; |
|
30 | - $this->info['font-family'] = $def->info['font-family']; |
|
25 | + $this->info[ 'font-style' ] = $def->info[ 'font-style' ]; |
|
26 | + $this->info[ 'font-variant' ] = $def->info[ 'font-variant' ]; |
|
27 | + $this->info[ 'font-weight' ] = $def->info[ 'font-weight' ]; |
|
28 | + $this->info[ 'font-size' ] = $def->info[ 'font-size' ]; |
|
29 | + $this->info[ 'line-height' ] = $def->info[ 'line-height' ]; |
|
30 | + $this->info[ 'font-family' ] = $def->info[ 'font-family' ]; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | // check if it's one of the keywords |
57 | 57 | $lowercase_string = strtolower($string); |
58 | - if (isset($system_fonts[$lowercase_string])) { |
|
58 | + if (isset($system_fonts[ $lowercase_string ])) { |
|
59 | 59 | return $lowercase_string; |
60 | 60 | } |
61 | 61 | |
@@ -66,23 +66,23 @@ discard block |
||
66 | 66 | $final = ''; // output |
67 | 67 | |
68 | 68 | for ($i = 0, $size = count($bits); $i < $size; $i++) { |
69 | - if ($bits[$i] === '') { |
|
69 | + if ($bits[ $i ] === '') { |
|
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | switch ($stage) { |
73 | 73 | case 0: // attempting to catch font-style, font-variant or font-weight |
74 | 74 | foreach ($stage_1 as $validator_name) { |
75 | - if (isset($caught[$validator_name])) { |
|
75 | + if (isset($caught[ $validator_name ])) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | - $r = $this->info[$validator_name]->validate( |
|
79 | - $bits[$i], |
|
78 | + $r = $this->info[ $validator_name ]->validate( |
|
79 | + $bits[ $i ], |
|
80 | 80 | $config, |
81 | 81 | $context |
82 | 82 | ); |
83 | 83 | if ($r !== false) { |
84 | - $final .= $r . ' '; |
|
85 | - $caught[$validator_name] = true; |
|
84 | + $final .= $r.' '; |
|
85 | + $caught[ $validator_name ] = true; |
|
86 | 86 | break; |
87 | 87 | } |
88 | 88 | } |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | } |
96 | 96 | case 1: // attempting to catch font-size and perhaps line-height |
97 | 97 | $found_slash = false; |
98 | - if (strpos($bits[$i], '/') !== false) { |
|
98 | + if (strpos($bits[ $i ], '/') !== false) { |
|
99 | 99 | list($font_size, $line_height) = |
100 | - explode('/', $bits[$i]); |
|
100 | + explode('/', $bits[ $i ]); |
|
101 | 101 | if ($line_height === '') { |
102 | 102 | // ooh, there's a space after the slash! |
103 | 103 | $line_height = false; |
104 | 104 | $found_slash = true; |
105 | 105 | } |
106 | 106 | } else { |
107 | - $font_size = $bits[$i]; |
|
107 | + $font_size = $bits[ $i ]; |
|
108 | 108 | $line_height = false; |
109 | 109 | } |
110 | - $r = $this->info['font-size']->validate( |
|
110 | + $r = $this->info[ 'font-size' ]->validate( |
|
111 | 111 | $font_size, |
112 | 112 | $config, |
113 | 113 | $context |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | if ($line_height === false) { |
119 | 119 | // we need to scroll forward |
120 | 120 | for ($j = $i + 1; $j < $size; $j++) { |
121 | - if ($bits[$j] === '') { |
|
121 | + if ($bits[ $j ] === '') { |
|
122 | 122 | continue; |
123 | 123 | } |
124 | - if ($bits[$j] === '/') { |
|
124 | + if ($bits[ $j ] === '/') { |
|
125 | 125 | if ($found_slash) { |
126 | 126 | return false; |
127 | 127 | } else { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | continue; |
130 | 130 | } |
131 | 131 | } |
132 | - $line_height = $bits[$j]; |
|
132 | + $line_height = $bits[ $j ]; |
|
133 | 133 | break; |
134 | 134 | } |
135 | 135 | } else { |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | } |
140 | 140 | if ($found_slash) { |
141 | 141 | $i = $j; |
142 | - $r = $this->info['line-height']->validate( |
|
142 | + $r = $this->info[ 'line-height' ]->validate( |
|
143 | 143 | $line_height, |
144 | 144 | $config, |
145 | 145 | $context |
146 | 146 | ); |
147 | 147 | if ($r !== false) { |
148 | - $final .= '/' . $r; |
|
148 | + $final .= '/'.$r; |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | $final .= ' '; |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | case 2: // attempting to catch font-family |
157 | 157 | $font_family = |
158 | 158 | implode(' ', array_slice($bits, $i, $size - $i)); |
159 | - $r = $this->info['font-family']->validate( |
|
159 | + $r = $this->info[ 'font-family' ]->validate( |
|
160 | 160 | $font_family, |
161 | 161 | $config, |
162 | 162 | $context |
163 | 163 | ); |
164 | 164 | if ($r !== false) { |
165 | - $final .= $r . ' '; |
|
165 | + $final .= $r.' '; |
|
166 | 166 | // processing completed successfully |
167 | 167 | return rtrim($final); |
168 | 168 | } |
@@ -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 | { |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | public function __construct($config) |
19 | 19 | { |
20 | 20 | $def = $config->getCSSDefinition(); |
21 | - $this->info['border-width'] = $def->info['border-width']; |
|
22 | - $this->info['border-style'] = $def->info['border-style']; |
|
23 | - $this->info['border-top-color'] = $def->info['border-top-color']; |
|
21 | + $this->info[ 'border-width' ] = $def->info[ 'border-width' ]; |
|
22 | + $this->info[ 'border-style' ] = $def->info[ 'border-style' ]; |
|
23 | + $this->info[ 'border-top-color' ] = $def->info[ 'border-top-color' ]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | $ret = ''; // return value |
39 | 39 | foreach ($bits as $bit) { |
40 | 40 | foreach ($this->info as $propname => $validator) { |
41 | - if (isset($done[$propname])) { |
|
41 | + if (isset($done[ $propname ])) { |
|
42 | 42 | continue; |
43 | 43 | } |
44 | 44 | $r = $validator->validate($bit, $config, $context); |
45 | 45 | if ($r !== false) { |
46 | - $ret .= $r . ' '; |
|
47 | - $done[$propname] = true; |
|
46 | + $ret .= $r.' '; |
|
47 | + $done[ $propname ] = true; |
|
48 | 48 | break; |
49 | 49 | } |
50 | 50 | } |
@@ -34,15 +34,15 @@ |
||
34 | 34 | } |
35 | 35 | $uri_string = substr($uri_string, 4); |
36 | 36 | $new_length = strlen($uri_string) - 1; |
37 | - if ($uri_string[$new_length] != ')') { |
|
37 | + if ($uri_string[ $new_length ] != ')') { |
|
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | $uri = trim(substr($uri_string, 0, $new_length)); |
41 | 41 | |
42 | - if (!empty($uri) && ($uri[0] == "'" || $uri[0] == '"')) { |
|
43 | - $quote = $uri[0]; |
|
42 | + if (!empty($uri) && ($uri[ 0 ] == "'" || $uri[ 0 ] == '"')) { |
|
43 | + $quote = $uri[ 0 ]; |
|
44 | 44 | $new_length = strlen($uri) - 1; |
45 | - if ($uri[$new_length] !== $quote) { |
|
45 | + if ($uri[ $new_length ] !== $quote) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | $uri = substr($uri, 1, $new_length - 1); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | public function validate($string, $config, $context) |
37 | 37 | { |
38 | 38 | foreach ($this->defs as $i => $def) { |
39 | - $result = $this->defs[$i]->validate($string, $config, $context); |
|
39 | + $result = $this->defs[ $i ]->validate($string, $config, $context); |
|
40 | 40 | if ($result !== false) { |
41 | 41 | return $result; |
42 | 42 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | if ($length === 1) { |
38 | 38 | return false; |
39 | 39 | } |
40 | - if ($string[$length - 1] !== '%') { |
|
40 | + if ($string[ $length - 1 ] !== '%') { |
|
41 | 41 | return false; |
42 | 42 | } |
43 | 43 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | list($key, $value) = explode('=', $param); |
49 | 49 | $key = trim($key); |
50 | 50 | $value = trim($value); |
51 | - if (isset($lookup[$key])) { |
|
51 | + if (isset($lookup[ $key ])) { |
|
52 | 52 | continue; |
53 | 53 | } |
54 | 54 | if ($key !== 'opacity') { |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | if ($value === false) { |
59 | 59 | continue; |
60 | 60 | } |
61 | - $int = (int)$value; |
|
61 | + $int = (int) $value; |
|
62 | 62 | if ($int > 100) { |
63 | 63 | $value = '100'; |
64 | 64 | } |
65 | 65 | if ($int < 0) { |
66 | 66 | $value = '0'; |
67 | 67 | } |
68 | - $ret_params[] = "$key=$value"; |
|
69 | - $lookup[$key] = true; |
|
68 | + $ret_params[ ] = "$key=$value"; |
|
69 | + $lookup[ $key ] = true; |
|
70 | 70 | } |
71 | 71 | $ret_parameters = implode(',', $ret_params); |
72 | 72 | $ret_function = "$function($ret_parameters)"; |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | $bits = explode(' ', $string); |
73 | 73 | |
74 | 74 | $keywords = array(); |
75 | - $keywords['h'] = false; // left, right |
|
76 | - $keywords['v'] = false; // top, bottom |
|
77 | - $keywords['ch'] = false; // center (first word) |
|
78 | - $keywords['cv'] = false; // center (second word) |
|
75 | + $keywords[ 'h' ] = false; // left, right |
|
76 | + $keywords[ 'v' ] = false; // top, bottom |
|
77 | + $keywords[ 'ch' ] = false; // center (first word) |
|
78 | + $keywords[ 'cv' ] = false; // center (second word) |
|
79 | 79 | $measures = array(); |
80 | 80 | |
81 | 81 | $i = 0; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | |
96 | 96 | // test for keyword |
97 | 97 | $lbit = ctype_lower($bit) ? $bit : strtolower($bit); |
98 | - if (isset($lookup[$lbit])) { |
|
99 | - $status = $lookup[$lbit]; |
|
98 | + if (isset($lookup[ $lbit ])) { |
|
99 | + $status = $lookup[ $lbit ]; |
|
100 | 100 | if ($status == 'c') { |
101 | 101 | if ($i == 0) { |
102 | 102 | $status = 'ch'; |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | $status = 'cv'; |
105 | 105 | } |
106 | 106 | } |
107 | - $keywords[$status] = $lbit; |
|
107 | + $keywords[ $status ] = $lbit; |
|
108 | 108 | $i++; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // test for length |
112 | 112 | $r = $this->length->validate($bit, $config, $context); |
113 | 113 | if ($r !== false) { |
114 | - $measures[] = $r; |
|
114 | + $measures[ ] = $r; |
|
115 | 115 | $i++; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // test for percentage |
119 | 119 | $r = $this->percentage->validate($bit, $config, $context); |
120 | 120 | if ($r !== false) { |
121 | - $measures[] = $r; |
|
121 | + $measures[ ] = $r; |
|
122 | 122 | $i++; |
123 | 123 | } |
124 | 124 | } |
@@ -130,21 +130,21 @@ discard block |
||
130 | 130 | $ret = array(); |
131 | 131 | |
132 | 132 | // first keyword |
133 | - if ($keywords['h']) { |
|
134 | - $ret[] = $keywords['h']; |
|
135 | - } elseif ($keywords['ch']) { |
|
136 | - $ret[] = $keywords['ch']; |
|
137 | - $keywords['cv'] = false; // prevent re-use: center = center center |
|
133 | + if ($keywords[ 'h' ]) { |
|
134 | + $ret[ ] = $keywords[ 'h' ]; |
|
135 | + } elseif ($keywords[ 'ch' ]) { |
|
136 | + $ret[ ] = $keywords[ 'ch' ]; |
|
137 | + $keywords[ 'cv' ] = false; // prevent re-use: center = center center |
|
138 | 138 | } elseif (count($measures)) { |
139 | - $ret[] = array_shift($measures); |
|
139 | + $ret[ ] = array_shift($measures); |
|
140 | 140 | } |
141 | 141 | |
142 | - if ($keywords['v']) { |
|
143 | - $ret[] = $keywords['v']; |
|
144 | - } elseif ($keywords['cv']) { |
|
145 | - $ret[] = $keywords['cv']; |
|
142 | + if ($keywords[ 'v' ]) { |
|
143 | + $ret[ ] = $keywords[ 'v' ]; |
|
144 | + } elseif ($keywords[ 'cv' ]) { |
|
145 | + $ret[ ] = $keywords[ 'cv' ]; |
|
146 | 146 | } elseif (count($measures)) { |
147 | - $ret[] = array_shift($measures); |
|
147 | + $ret[ ] = array_shift($measures); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | if (empty($ret)) { |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | if ($string === '') { |
43 | 43 | return ''; |
44 | 44 | } |
45 | - if ($length > 1 && $string[0] === '[' && $string[$length - 1] === ']') { |
|
45 | + if ($length > 1 && $string[ 0 ] === '[' && $string[ $length - 1 ] === ']') { |
|
46 | 46 | //IPv6 |
47 | 47 | $ip = substr($string, 1, $length - 2); |
48 | 48 | $valid = $this->ipv6->validate($ip, $config, $context); |
49 | 49 | if ($valid === false) { |
50 | 50 | return false; |
51 | 51 | } |
52 | - return '[' . $valid . ']'; |
|
52 | + return '['.$valid.']'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // need to do checks on unusual encodings too |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | $underscore = $config->get('Core.AllowHostnameUnderscore') ? '_' : ''; |
78 | 78 | |
79 | 79 | // The productions describing this are: |
80 | - $a = '[a-z]'; // alpha |
|
81 | - $an = '[a-z0-9]'; // alphanum |
|
80 | + $a = '[a-z]'; // alpha |
|
81 | + $an = '[a-z0-9]'; // alphanum |
|
82 | 82 | $and = "[a-z0-9-$underscore]"; // alphanum | "-" |
83 | 83 | // domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum |
84 | 84 | $domainlabel = "$an($and*$an)?"; |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | foreach ($parts as $part) { |
103 | 103 | $encodable = false; |
104 | 104 | for ($i = 0, $c = strlen($part); $i < $c; $i++) { |
105 | - if (ord($part[$i]) > 0x7a) { |
|
105 | + if (ord($part[ $i ]) > 0x7a) { |
|
106 | 106 | $encodable = true; |
107 | 107 | break; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | if (!$encodable) { |
111 | - $new_parts[] = $part; |
|
111 | + $new_parts[ ] = $part; |
|
112 | 112 | } else { |
113 | - $new_parts[] = $idna->encode($part); |
|
113 | + $new_parts[ ] = $idna->encode($part); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | $string = implode('.', $new_parts); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | $this->_loadRegex(); |
26 | 26 | } |
27 | 27 | |
28 | - if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) { |
|
28 | + if (preg_match('#^'.$this->ip4.'$#s', $aIP)) { |
|
29 | 29 | return $aIP; |
30 | 30 | } |
31 | 31 | return false; |