@@ -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 | |
@@ -46,7 +46,9 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function toArray($t = NULL) { |
| 48 | 48 | $a = $this->front; |
| 49 | - if ($t !== NULL) $a[] = $t; |
|
| 49 | + if ($t !== NULL) { |
|
| 50 | + $a[] = $t; |
|
| 51 | + } |
|
| 50 | 52 | for ($i = count($this->back)-1; $i >= 0; $i--) { |
| 51 | 53 | $a[] = $this->back[$i]; |
| 52 | 54 | } |
@@ -59,7 +61,9 @@ discard block |
||
| 59 | 61 | * @return Original contents of new hole. |
| 60 | 62 | */ |
| 61 | 63 | public function next($t) { |
| 62 | - if ($t !== NULL) array_push($this->front, $t); |
|
| 64 | + if ($t !== NULL) { |
|
| 65 | + array_push($this->front, $t); |
|
| 66 | + } |
|
| 63 | 67 | return empty($this->back) ? NULL : array_pop($this->back); |
| 64 | 68 | } |
| 65 | 69 | |
@@ -82,7 +86,9 @@ discard block |
||
| 82 | 86 | * @return Original contents of new hole. |
| 83 | 87 | */ |
| 84 | 88 | public function prev($t) { |
| 85 | - if ($t !== NULL) array_push($this->back, $t); |
|
| 89 | + if ($t !== NULL) { |
|
| 90 | + array_push($this->back, $t); |
|
| 91 | + } |
|
| 86 | 92 | return empty($this->front) ? NULL : array_pop($this->front); |
| 87 | 93 | } |
| 88 | 94 | |
@@ -108,7 +114,9 @@ discard block |
||
| 108 | 114 | * @param Element to insert |
| 109 | 115 | */ |
| 110 | 116 | public function insertBefore($t) { |
| 111 | - if ($t !== NULL) array_push($this->front, $t); |
|
| 117 | + if ($t !== NULL) { |
|
| 118 | + array_push($this->front, $t); |
|
| 119 | + } |
|
| 112 | 120 | } |
| 113 | 121 | |
| 114 | 122 | /** |
@@ -116,7 +124,9 @@ discard block |
||
| 116 | 124 | * @param Element to insert |
| 117 | 125 | */ |
| 118 | 126 | public function insertAfter($t) { |
| 119 | - if ($t !== NULL) array_push($this->back, $t); |
|
| 127 | + if ($t !== NULL) { |
|
| 128 | + array_push($this->back, $t); |
|
| 129 | + } |
|
| 120 | 130 | } |
| 121 | 131 | |
| 122 | 132 | /** |
@@ -41,7 +41,10 @@ |
||
| 41 | 41 | $matches = array(); |
| 42 | 42 | $result = preg_match($r_URI, $uri, $matches); |
| 43 | 43 | |
| 44 | - if (!$result) return false; // *really* invalid URI |
|
| 44 | + if (!$result) { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | + // *really* invalid URI |
|
| 45 | 48 | |
| 46 | 49 | // seperate out parts |
| 47 | 50 | $scheme = !empty($matches[1]) ? $matches[2] : null; |
@@ -128,19 +128,25 @@ discard block |
||
| 128 | 128 | break; |
| 129 | 129 | } |
| 130 | 130 | }; |
| 131 | - if ($go) continue; |
|
| 131 | + if ($go) { |
|
| 132 | + continue; |
|
| 133 | + } |
|
| 132 | 134 | list($token, $d) = $node->toTokenPair(); |
| 133 | 135 | // base case |
| 134 | 136 | if ($excludes_enabled && isset($excludes[$node->name])) { |
| 135 | 137 | $node->dead = true; |
| 136 | - if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node excluded'); |
|
| 138 | + if ($e) { |
|
| 139 | + $e->send(E_ERROR, 'Strategy_FixNesting: Node excluded'); |
|
| 140 | + } |
|
| 137 | 141 | } else { |
| 138 | 142 | // XXX I suppose it would be slightly more efficient to |
| 139 | 143 | // avoid the allocation here and have children |
| 140 | 144 | // strategies handle it |
| 141 | 145 | $children = array(); |
| 142 | 146 | foreach ($node->children as $child) { |
| 143 | - if (!$child->dead) $children[] = $child; |
|
| 147 | + if (!$child->dead) { |
|
| 148 | + $children[] = $child; |
|
| 149 | + } |
|
| 144 | 150 | } |
| 145 | 151 | $result = $def->child->validateChildren($children, $config, $context); |
| 146 | 152 | if ($result === true) { |
@@ -148,7 +154,9 @@ discard block |
||
| 148 | 154 | $node->children = $children; |
| 149 | 155 | } elseif ($result === false) { |
| 150 | 156 | $node->dead = true; |
| 151 | - if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node removed'); |
|
| 157 | + if ($e) { |
|
| 158 | + $e->send(E_ERROR, 'Strategy_FixNesting: Node removed'); |
|
| 159 | + } |
|
| 152 | 160 | } else { |
| 153 | 161 | $node->children = $result; |
| 154 | 162 | if ($e) { |
@@ -162,7 +162,9 @@ |
||
| 162 | 162 | $rewind_offset = $this->injectors[$i]->getRewindOffset(); |
| 163 | 163 | if (is_int($rewind_offset)) { |
| 164 | 164 | for ($j = 0; $j < $rewind_offset; $j++) { |
| 165 | - if (empty($zipper->front)) break; |
|
| 165 | + if (empty($zipper->front)) { |
|
| 166 | + break; |
|
| 167 | + } |
|
| 166 | 168 | $token = $zipper->prev($token); |
| 167 | 169 | // indicate that other injectors should not process this token, |
| 168 | 170 | // but we need to reprocess it |
@@ -42,7 +42,10 @@ discard block |
||
| 42 | 42 | public function addFilter($filter, $config) |
| 43 | 43 | { |
| 44 | 44 | $r = $filter->prepare($config); |
| 45 | - if ($r === false) return; // null is ok, for backwards compat |
|
| 45 | + if ($r === false) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 48 | + // null is ok, for backwards compat |
|
| 46 | 49 | if ($filter->post) { |
| 47 | 50 | $this->postFilters[$filter->name] = $filter; |
| 48 | 51 | } else { |
@@ -79,9 +82,13 @@ discard block |
||
| 79 | 82 | $parser = new HTMLPurifier_URIParser(); |
| 80 | 83 | $this->base = $parser->parse($base_uri); |
| 81 | 84 | $this->defaultScheme = $this->base->scheme; |
| 82 | - if (is_null($this->host)) $this->host = $this->base->host; |
|
| 85 | + if (is_null($this->host)) { |
|
| 86 | + $this->host = $this->base->host; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + if (is_null($this->defaultScheme)) { |
|
| 90 | + $this->defaultScheme = $config->get('URI.DefaultScheme'); |
|
| 83 | 91 | } |
| 84 | - if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI.DefaultScheme'); |
|
| 85 | 92 | } |
| 86 | 93 | |
| 87 | 94 | public function getDefaultScheme($config, $context) |
@@ -93,7 +100,9 @@ discard block |
||
| 93 | 100 | { |
| 94 | 101 | foreach ($this->filters as $name => $f) { |
| 95 | 102 | $result = $f->filter($uri, $config, $context); |
| 96 | - if (!$result) return false; |
|
| 103 | + if (!$result) { |
|
| 104 | + return false; |
|
| 105 | + } |
|
| 97 | 106 | } |
| 98 | 107 | return true; |
| 99 | 108 | } |
@@ -102,7 +111,9 @@ discard block |
||
| 102 | 111 | { |
| 103 | 112 | foreach ($this->postFilters as $name => $f) { |
| 104 | 113 | $result = $f->filter($uri, $config, $context); |
| 105 | - if (!$result) return false; |
|
| 114 | + if (!$result) { |
|
| 115 | + return false; |
|
| 116 | + } |
|
| 106 | 117 | } |
| 107 | 118 | return true; |
| 108 | 119 | } |
@@ -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; |
@@ -105,7 +105,9 @@ |
||
| 105 | 105 | break; |
| 106 | 106 | case 'caption': |
| 107 | 107 | // there can only be one caption! |
| 108 | - if ($caption !== false) break; |
|
| 108 | + if ($caption !== false) { |
|
| 109 | + break; |
|
| 110 | + } |
|
| 109 | 111 | $caption = $node; |
| 110 | 112 | $ws_accum =& $after_caption_ws; |
| 111 | 113 | break; |
@@ -38,8 +38,9 @@ discard block |
||
| 38 | 38 | $parser =& $parser_list[$parser_class]; |
| 39 | 39 | |
| 40 | 40 | # create the parser it not already set |
| 41 | - if (!$parser) |
|
| 42 | - $parser = new $parser_class; |
|
| 41 | + if (!$parser) { |
|
| 42 | + $parser = new $parser_class; |
|
| 43 | + } |
|
| 43 | 44 | |
| 44 | 45 | # Transform text using parser. |
| 45 | 46 | return $parser->transform($text); |
@@ -241,7 +242,9 @@ discard block |
||
| 241 | 242 | |
| 242 | 243 | |
| 243 | 244 | protected function hashHTMLBlocks($text) { |
| 244 | - if ($this->no_markup) return $text; |
|
| 245 | + if ($this->no_markup) { |
|
| 246 | + return $text; |
|
| 247 | + } |
|
| 245 | 248 | |
| 246 | 249 | $less_than_tab = $this->tab_width - 1; |
| 247 | 250 | |
@@ -529,7 +532,9 @@ discard block |
||
| 529 | 532 | # |
| 530 | 533 | # Turn Markdown link shortcuts into XHTML <a> tags. |
| 531 | 534 | # |
| 532 | - if ($this->in_anchor) return $text; |
|
| 535 | + if ($this->in_anchor) { |
|
| 536 | + return $text; |
|
| 537 | + } |
|
| 533 | 538 | $this->in_anchor = true; |
| 534 | 539 | |
| 535 | 540 | # |
@@ -623,8 +628,7 @@ discard block |
||
| 623 | 628 | $link_text = $this->runSpanGamut($link_text); |
| 624 | 629 | $result .= ">$link_text</a>"; |
| 625 | 630 | $result = $this->hashPart($result); |
| 626 | - } |
|
| 627 | - else { |
|
| 631 | + } else { |
|
| 628 | 632 | $result = $whole_match; |
| 629 | 633 | } |
| 630 | 634 | return $result; |
@@ -638,8 +642,9 @@ discard block |
||
| 638 | 642 | // if the URL was of the form <s p a c e s> it got caught by the HTML |
| 639 | 643 | // tag parser and hashed. Need to reverse the process before using the URL. |
| 640 | 644 | $unhashed = $this->unhash($url); |
| 641 | - if ($unhashed != $url) |
|
| 642 | - $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 645 | + if ($unhashed != $url) { |
|
| 646 | + $url = preg_replace('/^<(.*)>$/', '\1', $unhashed); |
|
| 647 | + } |
|
| 643 | 648 | |
| 644 | 649 | $url = $this->encodeURLAttribute($url); |
| 645 | 650 | |
@@ -731,8 +736,7 @@ discard block |
||
| 731 | 736 | } |
| 732 | 737 | $result .= $this->empty_element_suffix; |
| 733 | 738 | $result = $this->hashPart($result); |
| 734 | - } |
|
| 735 | - else { |
|
| 739 | + } else { |
|
| 736 | 740 | # If there's no such link ID, leave intact: |
| 737 | 741 | $result = $whole_match; |
| 738 | 742 | } |
@@ -791,8 +795,9 @@ discard block |
||
| 791 | 795 | |
| 792 | 796 | protected function _doHeaders_callback_setext($matches) { |
| 793 | 797 | # Terrible hack to check we haven't found an empty list item. |
| 794 | - if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) |
|
| 795 | - return $matches[0]; |
|
| 798 | + if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1])) { |
|
| 799 | + return $matches[0]; |
|
| 800 | + } |
|
| 796 | 801 | |
| 797 | 802 | $level = $matches[2]{0} == '=' ? 1 : 2; |
| 798 | 803 | |
@@ -823,7 +828,9 @@ discard block |
||
| 823 | 828 | return ""; |
| 824 | 829 | } |
| 825 | 830 | $idValue = call_user_func($this->header_id_func, $headerValue); |
| 826 | - if (!$idValue) return ""; |
|
| 831 | + if (!$idValue) { |
|
| 832 | + return ""; |
|
| 833 | + } |
|
| 827 | 834 | |
| 828 | 835 | return ' id="' . $this->encodeAttribute($idValue) . '"'; |
| 829 | 836 | |
@@ -882,8 +889,7 @@ discard block |
||
| 882 | 889 | '.$whole_list_re.' |
| 883 | 890 | }mx', |
| 884 | 891 | array($this, '_doLists_callback'), $text); |
| 885 | - } |
|
| 886 | - else { |
|
| 892 | + } else { |
|
| 887 | 893 | $text = preg_replace_callback('{ |
| 888 | 894 | (?:(?<=\n)\n|\A\n?) # Must eat the newline |
| 889 | 895 | '.$whole_list_re.' |
@@ -990,8 +996,7 @@ discard block |
||
| 990 | 996 | # Replace marker with the appropriate whitespace indentation |
| 991 | 997 | $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item; |
| 992 | 998 | $item = $this->runBlockGamut($this->outdent($item)."\n"); |
| 993 | - } |
|
| 994 | - else { |
|
| 999 | + } else { |
|
| 995 | 1000 | # Recursion for sub-lists: |
| 996 | 1001 | $item = $this->doLists($this->outdent($item)); |
| 997 | 1002 | $item = preg_replace('/\n+$/', '', $item); |
@@ -1261,8 +1266,7 @@ discard block |
||
| 1261 | 1266 | $value = preg_replace('/^([ ]*)/', "<p>", $value); |
| 1262 | 1267 | $value .= "</p>"; |
| 1263 | 1268 | $grafs[$key] = $this->unhash($value); |
| 1264 | - } |
|
| 1265 | - else { |
|
| 1269 | + } else { |
|
| 1266 | 1270 | # Is a block. |
| 1267 | 1271 | # Modify elements of @grafs in-place... |
| 1268 | 1272 | $graf = $value; |
@@ -1329,17 +1333,17 @@ discard block |
||
| 1329 | 1333 | # representation for the URL (removing mailto: or tel:) storing it in $text. |
| 1330 | 1334 | # This function is *not* suitable for attributes enclosed in single quotes. |
| 1331 | 1335 | # |
| 1332 | - if ($this->url_filter_func) |
|
| 1333 | - $url = call_user_func($this->url_filter_func, $url); |
|
| 1336 | + if ($this->url_filter_func) { |
|
| 1337 | + $url = call_user_func($this->url_filter_func, $url); |
|
| 1338 | + } |
|
| 1334 | 1339 | |
| 1335 | - if (preg_match('{^mailto:}i', $url)) |
|
| 1336 | - $url = $this->encodeEntityObfuscatedAttribute($url, $text, 7); |
|
| 1337 | - else if (preg_match('{^tel:}i', $url)) |
|
| 1340 | + if (preg_match('{^mailto:}i', $url)) { |
|
| 1341 | + $url = $this->encodeEntityObfuscatedAttribute($url, $text, 7); |
|
| 1342 | + } else if (preg_match('{^tel:}i', $url)) |
|
| 1338 | 1343 | { |
| 1339 | 1344 | $url = $this->encodeAttribute($url); |
| 1340 | 1345 | $text = substr($url, 4); |
| 1341 | - } |
|
| 1342 | - else |
|
| 1346 | + } else |
|
| 1343 | 1347 | { |
| 1344 | 1348 | $url = $this->encodeAttribute($url); |
| 1345 | 1349 | $text = $url; |
@@ -1429,7 +1433,9 @@ discard block |
||
| 1429 | 1433 | # With some optimizations by Milian Wolff. Forced encoding of HTML |
| 1430 | 1434 | # attribute special characters by Allan Odgaard. |
| 1431 | 1435 | # |
| 1432 | - if ($text == "") return $tail = ""; |
|
| 1436 | + if ($text == "") { |
|
| 1437 | + return $tail = ""; |
|
| 1438 | + } |
|
| 1433 | 1439 | |
| 1434 | 1440 | $chars = preg_split('/(?<!^)(?!$)/', $text); |
| 1435 | 1441 | $seed = (int)abs(crc32($text) / strlen($text)); # Deterministic seed. |
@@ -1443,8 +1449,11 @@ discard block |
||
| 1443 | 1449 | # '@' *must* be encoded. I insist. |
| 1444 | 1450 | # '"' and '>' have to be encoded inside the attribute |
| 1445 | 1451 | if ($r > 90 && strpos('@"&>', $char) === false) /* do nothing */; |
| 1446 | - else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1447 | - else $chars[$key] = '&#'.$ord.';'; |
|
| 1452 | + else if ($r < 45) { |
|
| 1453 | + $chars[$key] = '&#x'.dechex($ord).';'; |
|
| 1454 | + } else { |
|
| 1455 | + $chars[$key] = '&#'.$ord.';'; |
|
| 1456 | + } |
|
| 1448 | 1457 | } |
| 1449 | 1458 | } |
| 1450 | 1459 | |
@@ -1505,8 +1514,7 @@ discard block |
||
| 1505 | 1514 | if (isset($parts[1])) { |
| 1506 | 1515 | $output .= $this->handleSpanToken($parts[1], $parts[2]); |
| 1507 | 1516 | $str = $parts[2]; |
| 1508 | - } |
|
| 1509 | - else { |
|
| 1517 | + } else { |
|
| 1510 | 1518 | break; |
| 1511 | 1519 | } |
| 1512 | 1520 | } |
@@ -1588,7 +1596,9 @@ discard block |
||
| 1588 | 1596 | # function that will loosely count the number of UTF-8 characters with a |
| 1589 | 1597 | # regular expression. |
| 1590 | 1598 | # |
| 1591 | - if (function_exists($this->utf8_strlen)) return; |
|
| 1599 | + if (function_exists($this->utf8_strlen)) { |
|
| 1600 | + return; |
|
| 1601 | + } |
|
| 1592 | 1602 | $this->utf8_strlen = create_function('$text', 'return preg_match_all( |
| 1593 | 1603 | "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", |
| 1594 | 1604 | $text, $m);'); |