@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | } else { |
67 | - $data = $result[0]; |
|
67 | + $data = $result[ 0 ]; |
|
68 | 68 | } |
69 | - if ($content_type !== null && empty($this->allowed_types[$content_type])) { |
|
69 | + if ($content_type !== null && empty($this->allowed_types[ $content_type ])) { |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | if ($charset !== null) { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | if ($info == false) { |
95 | 95 | return false; |
96 | 96 | } |
97 | - $image_code = $info[2]; |
|
97 | + $image_code = $info[ 2 ]; |
|
98 | 98 | } else { |
99 | 99 | trigger_error("could not find exif_imagetype or getimagesize functions", E_USER_ERROR); |
100 | 100 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if ($real_content_type != $content_type) { |
103 | 103 | // we're nice guys; if the content type is something else we |
104 | 104 | // support, change it over |
105 | - if (empty($this->allowed_types[$real_content_type])) { |
|
105 | + if (empty($this->allowed_types[ $real_content_type ])) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | $content_type = $real_content_type; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $uri->port = null; |
114 | 114 | $uri->fragment = null; |
115 | 115 | $uri->query = null; |
116 | - $uri->path = "$content_type;base64," . base64_encode($raw_data); |
|
116 | + $uri->path = "$content_type;base64,".base64_encode($raw_data); |
|
117 | 117 | return true; |
118 | 118 | } |
119 | 119 |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function getChild($type, $id) |
56 | 56 | { |
57 | - if (!isset($this->children[$type][$id])) { |
|
58 | - $this->children[$type][$id] = new HTMLPurifier_ErrorStruct(); |
|
59 | - $this->children[$type][$id]->type = $type; |
|
57 | + if (!isset($this->children[ $type ][ $id ])) { |
|
58 | + $this->children[ $type ][ $id ] = new HTMLPurifier_ErrorStruct(); |
|
59 | + $this->children[ $type ][ $id ]->type = $type; |
|
60 | 60 | } |
61 | - return $this->children[$type][$id]; |
|
61 | + return $this->children[ $type ][ $id ]; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function addError($severity, $message) |
69 | 69 | { |
70 | - $this->errors[] = array($severity, $message); |
|
70 | + $this->errors[ ] = array($severity, $message); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $tidy->parseString( |
107 | 107 | $html, |
108 | 108 | array( |
109 | - 'indent'=> true, |
|
110 | - 'output-xhtml' => $this->_xhtml, |
|
111 | - 'show-body-only' => true, |
|
112 | - 'indent-spaces' => 2, |
|
113 | - 'wrap' => 68, |
|
109 | + 'indent'=> true, |
|
110 | + 'output-xhtml' => $this->_xhtml, |
|
111 | + 'show-body-only' => true, |
|
112 | + 'indent-spaces' => 2, |
|
113 | + 'wrap' => 68, |
|
114 | 114 | ), |
115 | 115 | 'utf8' |
116 | 116 | ); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $this->_flashStack[count($this->_flashStack)-1]->param[$token->attr['name']] = $token->attr['value']; |
169 | 169 | } |
170 | 170 | $attr = $this->generateAttributes($token->attr, $token->name); |
171 | - return '<' . $token->name . ($attr ? ' ' : '') . $attr . |
|
171 | + return '<' . $token->name . ($attr ? ' ' : '') . $attr . |
|
172 | 172 | ( $this->_xhtml ? ' /': '' ) // <br /> v. <br> |
173 | 173 | . '>'; |
174 | 174 |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | // Basic algorithm |
90 | 90 | $html = ''; |
91 | 91 | for ($i = 0, $size = count($tokens); $i < $size; $i++) { |
92 | - if ($this->_scriptFix && $tokens[$i]->name === 'script' |
|
93 | - && $i + 2 < $size && $tokens[$i+2] instanceof HTMLPurifier_Token_End) { |
|
92 | + if ($this->_scriptFix && $tokens[ $i ]->name === 'script' |
|
93 | + && $i + 2 < $size && $tokens[ $i + 2 ] instanceof HTMLPurifier_Token_End) { |
|
94 | 94 | // script special case |
95 | 95 | // the contents of the script block must be ONE token |
96 | 96 | // for this to work. |
97 | - $html .= $this->generateFromToken($tokens[$i++]); |
|
98 | - $html .= $this->generateScriptFromToken($tokens[$i++]); |
|
97 | + $html .= $this->generateFromToken($tokens[ $i++ ]); |
|
98 | + $html .= $this->generateScriptFromToken($tokens[ $i++ ]); |
|
99 | 99 | } |
100 | - $html .= $this->generateFromToken($tokens[$i]); |
|
100 | + $html .= $this->generateFromToken($tokens[ $i ]); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // Tidy cleanup |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | $flash = new stdclass(); |
150 | 150 | $flash->attr = $token->attr; |
151 | 151 | $flash->param = array(); |
152 | - $this->_flashStack[] = $flash; |
|
152 | + $this->_flashStack[ ] = $flash; |
|
153 | 153 | } |
154 | 154 | } |
155 | - return '<' . $token->name . ($attr ? ' ' : '') . $attr . '>'; |
|
155 | + return '<'.$token->name.($attr ? ' ' : '').$attr.'>'; |
|
156 | 156 | |
157 | 157 | } elseif ($token instanceof HTMLPurifier_Token_End) { |
158 | 158 | $_extra = ''; |
@@ -161,22 +161,22 @@ discard block |
||
161 | 161 | // doesn't do anything for now |
162 | 162 | } |
163 | 163 | } |
164 | - return $_extra . '</' . $token->name . '>'; |
|
164 | + return $_extra.'</'.$token->name.'>'; |
|
165 | 165 | |
166 | 166 | } elseif ($token instanceof HTMLPurifier_Token_Empty) { |
167 | 167 | if ($this->_flashCompat && $token->name == "param" && !empty($this->_flashStack)) { |
168 | - $this->_flashStack[count($this->_flashStack)-1]->param[$token->attr['name']] = $token->attr['value']; |
|
168 | + $this->_flashStack[ count($this->_flashStack) - 1 ]->param[ $token->attr[ 'name' ] ] = $token->attr[ 'value' ]; |
|
169 | 169 | } |
170 | 170 | $attr = $this->generateAttributes($token->attr, $token->name); |
171 | - return '<' . $token->name . ($attr ? ' ' : '') . $attr . |
|
172 | - ( $this->_xhtml ? ' /': '' ) // <br /> v. <br> |
|
171 | + return '<'.$token->name.($attr ? ' ' : '').$attr. |
|
172 | + ($this->_xhtml ? ' /' : '') // <br /> v. <br> |
|
173 | 173 | . '>'; |
174 | 174 | |
175 | 175 | } elseif ($token instanceof HTMLPurifier_Token_Text) { |
176 | 176 | return $this->escape($token->data, ENT_NOQUOTES); |
177 | 177 | |
178 | 178 | } elseif ($token instanceof HTMLPurifier_Token_Comment) { |
179 | - return '<!--' . $token->data . '-->'; |
|
179 | + return '<!--'.$token->data.'-->'; |
|
180 | 180 | } else { |
181 | 181 | return ''; |
182 | 182 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | } |
198 | 198 | // Thanks <http://lachy.id.au/log/2005/05/script-comments> |
199 | 199 | $data = preg_replace('#//\s*$#', '', $token->data); |
200 | - return '<!--//--><![CDATA[//><!--' . "\n" . trim($data) . "\n" . '//--><!]]>'; |
|
200 | + return '<!--//--><![CDATA[//><!--'."\n".trim($data)."\n".'//--><!]]>'; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | // Check if we should minimize the attribute: val="val" -> val |
224 | - if ($element && !empty($this->_def->info[$element]->attr[$key]->minimized)) { |
|
225 | - $html .= $key . ' '; |
|
224 | + if ($element && !empty($this->_def->info[ $element ]->attr[ $key ]->minimized)) { |
|
225 | + $html .= $key.' '; |
|
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | } |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | $next = false; |
61 | 61 | $deleted = 1; // the current tag |
62 | 62 | for ($i = count($this->inputZipper->back) - 1; $i >= 0; $i--, $deleted++) { |
63 | - $next = $this->inputZipper->back[$i]; |
|
63 | + $next = $this->inputZipper->back[ $i ]; |
|
64 | 64 | if ($next instanceof HTMLPurifier_Token_Text) { |
65 | 65 | if ($next->is_whitespace) { |
66 | 66 | continue; |
67 | 67 | } |
68 | - if ($this->removeNbsp && !isset($this->removeNbspExceptions[$token->name])) { |
|
68 | + if ($this->removeNbsp && !isset($this->removeNbspExceptions[ $token->name ])) { |
|
69 | 69 | $plain = str_replace("\xC2\xA0", "", $next->data); |
70 | 70 | $isWsOrNbsp = $plain === '' || ctype_space($plain); |
71 | 71 | if ($isWsOrNbsp) { |
@@ -77,27 +77,27 @@ discard block |
||
77 | 77 | } |
78 | 78 | if (!$next || ($next instanceof HTMLPurifier_Token_End && $next->name == $token->name)) { |
79 | 79 | $this->attrValidator->validateToken($token, $this->config, $this->context); |
80 | - $token->armor['ValidateAttributes'] = true; |
|
81 | - if (isset($this->exclude[$token->name])) { |
|
80 | + $token->armor[ 'ValidateAttributes' ] = true; |
|
81 | + if (isset($this->exclude[ $token->name ])) { |
|
82 | 82 | $r = true; |
83 | - foreach ($this->exclude[$token->name] as $elem) { |
|
84 | - if (!isset($token->attr[$elem])) $r = false; |
|
83 | + foreach ($this->exclude[ $token->name ] as $elem) { |
|
84 | + if (!isset($token->attr[ $elem ])) $r = false; |
|
85 | 85 | } |
86 | 86 | if ($r) return; |
87 | 87 | } |
88 | - if (isset($token->attr['id']) || isset($token->attr['name'])) { |
|
88 | + if (isset($token->attr[ 'id' ]) || isset($token->attr[ 'name' ])) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | $token = $deleted + 1; |
92 | 92 | for ($b = 0, $c = count($this->inputZipper->front); $b < $c; $b++) { |
93 | - $prev = $this->inputZipper->front[$b]; |
|
93 | + $prev = $this->inputZipper->front[ $b ]; |
|
94 | 94 | if ($prev instanceof HTMLPurifier_Token_Text && $prev->is_whitespace) { |
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | break; |
98 | 98 | } |
99 | 99 | // This is safe because we removed the token that triggered this. |
100 | - $this->rewindOffset($b+$deleted); |
|
100 | + $this->rewindOffset($b + $deleted); |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | } |
@@ -81,9 +81,13 @@ |
||
81 | 81 | if (isset($this->exclude[$token->name])) { |
82 | 82 | $r = true; |
83 | 83 | foreach ($this->exclude[$token->name] as $elem) { |
84 | - if (!isset($token->attr[$elem])) $r = false; |
|
84 | + if (!isset($token->attr[$elem])) { |
|
85 | + $r = false; |
|
86 | + } |
|
87 | + } |
|
88 | + if ($r) { |
|
89 | + return; |
|
85 | 90 | } |
86 | - if ($r) return; |
|
87 | 91 | } |
88 | 92 | if (isset($token->attr['id']) || isset($token->attr['name'])) { |
89 | 93 | return; |
@@ -62,38 +62,38 @@ |
||
62 | 62 | public function handleElement(&$token) |
63 | 63 | { |
64 | 64 | if ($token->name == 'object') { |
65 | - $this->objectStack[] = $token; |
|
66 | - $this->paramStack[] = array(); |
|
65 | + $this->objectStack[ ] = $token; |
|
66 | + $this->paramStack[ ] = array(); |
|
67 | 67 | $new = array($token); |
68 | 68 | foreach ($this->addParam as $name => $value) { |
69 | - $new[] = new HTMLPurifier_Token_Empty('param', array('name' => $name, 'value' => $value)); |
|
69 | + $new[ ] = new HTMLPurifier_Token_Empty('param', array('name' => $name, 'value' => $value)); |
|
70 | 70 | } |
71 | 71 | $token = $new; |
72 | 72 | } elseif ($token->name == 'param') { |
73 | 73 | $nest = count($this->currentNesting) - 1; |
74 | - if ($nest >= 0 && $this->currentNesting[$nest]->name === 'object') { |
|
74 | + if ($nest >= 0 && $this->currentNesting[ $nest ]->name === 'object') { |
|
75 | 75 | $i = count($this->objectStack) - 1; |
76 | - if (!isset($token->attr['name'])) { |
|
76 | + if (!isset($token->attr[ 'name' ])) { |
|
77 | 77 | $token = false; |
78 | 78 | return; |
79 | 79 | } |
80 | - $n = $token->attr['name']; |
|
80 | + $n = $token->attr[ 'name' ]; |
|
81 | 81 | // We need this fix because YouTube doesn't supply a data |
82 | 82 | // attribute, which we need if a type is specified. This is |
83 | 83 | // *very* Flash specific. |
84 | - if (!isset($this->objectStack[$i]->attr['data']) && |
|
85 | - ($token->attr['name'] == 'movie' || $token->attr['name'] == 'src') |
|
84 | + if (!isset($this->objectStack[ $i ]->attr[ 'data' ]) && |
|
85 | + ($token->attr[ 'name' ] == 'movie' || $token->attr[ 'name' ] == 'src') |
|
86 | 86 | ) { |
87 | - $this->objectStack[$i]->attr['data'] = $token->attr['value']; |
|
87 | + $this->objectStack[ $i ]->attr[ 'data' ] = $token->attr[ 'value' ]; |
|
88 | 88 | } |
89 | 89 | // Check if the parameter is the correct value but has not |
90 | 90 | // already been added |
91 | - if (!isset($this->paramStack[$i][$n]) && |
|
92 | - isset($this->addParam[$n]) && |
|
93 | - $token->attr['name'] === $this->addParam[$n]) { |
|
91 | + if (!isset($this->paramStack[ $i ][ $n ]) && |
|
92 | + isset($this->addParam[ $n ]) && |
|
93 | + $token->attr[ 'name' ] === $this->addParam[ $n ]) { |
|
94 | 94 | // keep token, and add to param stack |
95 | - $this->paramStack[$i][$n] = true; |
|
96 | - } elseif (isset($this->allowedParam[$n])) { |
|
95 | + $this->paramStack[ $i ][ $n ] = true; |
|
96 | + } elseif (isset($this->allowedParam[ $n ])) { |
|
97 | 97 | // keep token, don't do anything to it |
98 | 98 | // (could possibly check for duplicates here) |
99 | 99 | } else { |
@@ -43,14 +43,14 @@ |
||
43 | 43 | // $l = is link |
44 | 44 | for ($i = 0, $c = count($bits), $l = false; $i < $c; $i++, $l = !$l) { |
45 | 45 | if (!$l) { |
46 | - if ($bits[$i] === '') { |
|
46 | + if ($bits[ $i ] === '') { |
|
47 | 47 | continue; |
48 | 48 | } |
49 | - $token[] = new HTMLPurifier_Token_Text($bits[$i]); |
|
49 | + $token[ ] = new HTMLPurifier_Token_Text($bits[ $i ]); |
|
50 | 50 | } else { |
51 | - $token[] = new HTMLPurifier_Token_Start('a', array('href' => $bits[$i])); |
|
52 | - $token[] = new HTMLPurifier_Token_Text($bits[$i]); |
|
53 | - $token[] = new HTMLPurifier_Token_End('a'); |
|
51 | + $token[ ] = new HTMLPurifier_Token_Start('a', array('href' => $bits[ $i ])); |
|
52 | + $token[ ] = new HTMLPurifier_Token_Text($bits[ $i ]); |
|
53 | + $token[ ] = new HTMLPurifier_Token_End('a'); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
@@ -52,7 +52,7 @@ |
||
52 | 52 | // happen until after MakeWellFormed. If all the attributes are removed |
53 | 53 | // the span needs to be removed too. |
54 | 54 | $this->attrValidator->validateToken($token, $this->config, $this->context); |
55 | - $token->armor['ValidateAttributes'] = true; |
|
55 | + $token->armor[ 'ValidateAttributes' ] = true; |
|
56 | 56 | |
57 | 57 | if (!empty($token->attr)) { |
58 | 58 | return; |
@@ -52,17 +52,17 @@ |
||
52 | 52 | // $l = is link |
53 | 53 | for ($i = 0, $c = count($bits), $l = false; $i < $c; $i++, $l = !$l) { |
54 | 54 | if (!$l) { |
55 | - if ($bits[$i] === '') { |
|
55 | + if ($bits[ $i ] === '') { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | - $token[] = new HTMLPurifier_Token_Text($bits[$i]); |
|
58 | + $token[ ] = new HTMLPurifier_Token_Text($bits[ $i ]); |
|
59 | 59 | } else { |
60 | - $token[] = new HTMLPurifier_Token_Start( |
|
60 | + $token[ ] = new HTMLPurifier_Token_Start( |
|
61 | 61 | 'a', |
62 | - array('href' => str_replace('%s', $bits[$i], $this->docURL)) |
|
62 | + array('href' => str_replace('%s', $bits[ $i ], $this->docURL)) |
|
63 | 63 | ); |
64 | - $token[] = new HTMLPurifier_Token_Text('%' . $bits[$i]); |
|
65 | - $token[] = new HTMLPurifier_Token_End('a'); |
|
64 | + $token[ ] = new HTMLPurifier_Token_Text('%'.$bits[ $i ]); |
|
65 | + $token[ ] = new HTMLPurifier_Token_End('a'); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -27,9 +27,9 @@ |
||
27 | 27 | */ |
28 | 28 | public function handleEnd(&$token) |
29 | 29 | { |
30 | - if (isset($token->start->attr['href'])) { |
|
31 | - $url = $token->start->attr['href']; |
|
32 | - unset($token->start->attr['href']); |
|
30 | + if (isset($token->start->attr[ 'href' ])) { |
|
31 | + $url = $token->start->attr[ 'href' ]; |
|
32 | + unset($token->start->attr[ 'href' ]); |
|
33 | 33 | $token = array($token, new HTMLPurifier_Token_Text(" ($url)")); |
34 | 34 | } else { |
35 | 35 | // nothing to display |