PluginProbe
bbPress / 2.6.6
bbPress v2.6.6
trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.2.2 All 71 releases
← All changes | includes/admin/parser.php +27 -10 2.22.6.6 View file →
@@ -1,5 +1,13 @@
1 1 <?php
2 +
3 +/**
4 + * bbPress BBCode Parser
5 + *
6 + * @package bbPress
7 + * @subpackage Administration
8 + */
9 +
2 10 /*
3 11 This is a compressed copy of NBBC. Do not edit!
4 12
5 13 Copyright (c) 2008-9, the Phantom Inker. All rights reserved.
@@ -79,9 +87,9 @@
79 87 var $pat_main;
80 88 var $pat_comment;
81 89 var $pat_comment2;
82 90 var $pat_wiki;
83 -function BBCodeLexer($string, $tagmarker = '[') {
91 +function __construct($string, $tagmarker = '[') {
84 92 $regex_beginmarkers = Array( '[' => '\[', '<' => '<', '{' => '\{', '(' => '\(' );
85 93 $regex_endmarkers = Array( '[' => '\]', '<' => '>', '{' => '\}', '(' => '\)' );
86 94 $endmarkers = Array( '[' => ']', '<' => '>', '{' => '}', '(' => ')' );
87 95 if (!isset($regex_endmarkers[$tagmarker])) $tagmarker = '[';
@@ -113,8 +121,11 @@
113 121 $this->token = BBCODE_EOI;
114 122 $this->tag = false;
115 123 $this->text = "";
116 124 }
125 +function BBCodeLexer($string, $tagmarker = '[') {
126 +$this->__construct($string, $tagmarker);
127 +}
117 128 function GuessTextLength() {
118 129 $length = 0;
119 130 $ptr = 0;
120 131 $state = BBCODE_LEXSTATE_TEXT;
@@ -210,9 +221,9 @@
210 221 $this->tag = false;
211 222 $this->state = BBCODE_LEXSTATE_TEXT;
212 223 if (strlen($this->text) > 0)
213 224 return $this->token = BBCODE_TEXT;
214 -continue;
225 +continue 2;
215 226 }
216 227 default:
217 228 $this->tag = false;
218 229 $this->state = BBCODE_LEXSTATE_TEXT;
@@ -222,13 +233,13 @@
222 233 case 91:
223 234 case 123:
224 235 if (preg_match($this->pat_comment, $this->text)) {
225 236 $this->state = BBCODE_LEXSTATE_TEXT;
226 -continue;
237 +continue 2;
227 238 }
228 239 if (preg_match($this->pat_comment2, $this->text)) {
229 240 $this->state = BBCODE_LEXSTATE_TEXT;
230 -continue;
241 +continue 2;
231 242 }
232 243 if (preg_match($this->pat_wiki, $this->text, $matches)) {
233 244 $this->tag = Array('_name' => 'wiki', '_endtag' => false,
234 245 '_default' => @$matches[1], 'title' => @$matches[2]);
@@ -1145,14 +1156,20 @@
1145 1156 }
1146 1157 function UnHTMLEncode($string) {
1147 1158 if (function_exists("html_entity_decode"))
1148 1159 return html_entity_decode($string);
1149 -$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
1150 -$string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string);
1160 +$string = preg_replace_callback('~&#x([0-9a-f]+);~i', array( $this, '_UnHTMLEncode_chr_callback'), $string);
1161 +$string = preg_replace_callback('~&#([0-9]+);~', array($this, '_UnHTMLEncode_chr_hexdec_callback'), $string);
1151 1162 $trans_tbl = get_html_translation_table(HTML_ENTITIES);
1152 1163 $trans_tbl = array_flip($trans_tbl);
1153 1164 return strtr($string, $trans_tbl);
1154 1165 }
1166 +function _UnHTMLEncode_chr_callback($match) {
1167 +return chr(hexdec($match[1]));
1168 +}
1169 +function _UnHTMLEncode_chr_hexdec_callback($match) {
1170 +return chr(hexdec($match[1]));
1171 +}
1155 1172 function Wikify($string) {
1156 1173 return rawurlencode(str_replace(" ", "_",
1157 1174 trim(preg_replace("/[!?;@#\$%\\^&*<>=+`~\\x00-\\x20_-]+/", " ", $string))));
1158 1175 }
@@ -1382,9 +1399,9 @@
1382 1399 if (isset($insert_array[$matches[1]]))
1383 1400 $value = @$insert_array[$matches[1]];
1384 1401 else $value = @$default_array[$matches[1]];
1385 1402 if (strlen(@$matches[2])) {
1386 -foreach (split(".", substr($matches[2], 1)) as $index) {
1403 +foreach (explode(".", substr($matches[2], 1)) as $index) {
1387 1404 if (is_array($value))
1388 1405 $value = @$value[$index];
1389 1406 else if (is_object($value)) {
1390 1407 $value = (array)$value;
@@ -1464,9 +1481,9 @@
1464 1481 $end = $this->Internal_CleanupWSByIteratingPointer(@$rule['before_endtag'], 0, $output);
1465 1482 $this->Internal_CleanupWSByPoppingStack(@$rule['after_tag'], $output);
1466 1483 $tag_body = $this->Internal_CollectTextReverse($output, count($output)-1, $end);
1467 1484 $this->Internal_CleanupWSByPoppingStack(@$rule['before_tag'], $this->stack);
1468 -$this->Internal_UpdateParamsForMissingEndTag(@$token[BBCODE_STACK_TAG]);
1485 +@$token[BBCODE_STACK_TAG]=@$this->Internal_UpdateParamsForMissingEndTag(@$token[BBCODE_STACK_TAG]);
1469 1486 $tag_output = $this->DoTag(BBCODE_OUTPUT, $name,
1470 1487 @$token[BBCODE_STACK_TAG]['_default'], @$token[BBCODE_STACK_TAG], $tag_body);
1471 1488 $output = Array(Array(
1472 1489 BBCODE_STACK_TOKEN => BBCODE_TEXT,
@@ -1761,9 +1778,9 @@
1761 1778 $params['_content'] = $contents;
1762 1779 $params['_defaultcontent'] = strlen(@$params['_default']) ? $params['_default'] : $contents;
1763 1780 return $this->FillTemplate(@$tag_rule['template'], $params, @$tag_rule['default']);
1764 1781 }
1765 -function Internal_UpdateParamsForMissingEndTag(&$params) {
1782 +function Internal_UpdateParamsForMissingEndTag($params) {
1766 1783 switch ($this->tag_marker) {
1767 1784 case '[': $tail_marker = ']'; break;
1768 1785 case '<': $tail_marker = '>'; break;
1769 1786 case '{': $tail_marker = '}'; break;
@@ -1770,8 +1787,9 @@
1770 1787 case '(': $tail_marker = ')'; break;
1771 1788 default: $tail_marker = $this->tag_marker; break;
1772 1789 }
1773 1790 $params['_endtag'] = $this->tag_marker . '/' . $params['_name'] . $tail_marker;
1791 +return $params;
1774 1792 }
1775 1793 function Internal_ProcessIsolatedTag($tag_name, $tag_params, $tag_rule) {
1776 1794 if (!$this->DoTag(BBCODE_CHECK, $tag_name, @$tag_params['_default'], $tag_params, "")) {
1777 1795 $this->stack[] = Array(
@@ -2069,5 +2087,4 @@
2069 2087 }
2070 2088 return $result;
2071 2089 }
2072 2090 }
2073 -