aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-05-19 16:29:50 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-05-19 16:29:50 +0200
commit3106195cddec48ec779282d03f2c54c88fc66511 (patch)
tree8f6d4fd9d5babb7f703f7e237e74f1a5bcdc4d17
parenta430fef05bcf034b790a2603879ada90fa5d1b71 (diff)
downloadforums-3106195cddec48ec779282d03f2c54c88fc66511.tar
forums-3106195cddec48ec779282d03f2c54c88fc66511.tar.gz
forums-3106195cddec48ec779282d03f2c54c88fc66511.tar.bz2
forums-3106195cddec48ec779282d03f2c54c88fc66511.tar.xz
forums-3106195cddec48ec779282d03f2c54c88fc66511.zip
[ticket/13832] Use preg_replace_callback in bbcode class
PHPBB3-13832
-rw-r--r--phpBB/includes/bbcode.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index dce9966efd..0c9869fe25 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -110,7 +110,18 @@ class bbcode
$undid_bbcode_specialchars = true;
}
- $message = preg_replace($preg['search'], $preg['replace'], $message);
+ foreach ($preg['search'] as $key => $search)
+ {
+ if (is_callable($preg['replace'][$key]))
+ {
+ $message = preg_replace_callback($search, $preg['replace'][$key], $message);
+ }
+ else
+ {
+ $message = preg_replace($search, $preg['replace'][$key], $message);
+ }
+ }
+
$preg = array('search' => array(), 'replace' => array());
}
}
@@ -212,7 +223,9 @@ class bbcode
'[/quote:$uid]' => $this->bbcode_tpl('quote_close', $bbcode_id)
),
'preg' => array(
- '#\[quote(?:=&quot;(.*?)&quot;)?:$uid\]((?!\[quote(?:=&quot;.*?&quot;)?:$uid\]).)?#ise' => "\$this->bbcode_second_pass_quote('\$1', '\$2')"
+ '#\[quote(?:=&quot;(.*?)&quot;)?:$uid\]((?!\[quote(?:=&quot;.*?&quot;)?:$uid\]).)?#is' => function ($match) {
+ return $this->bbcode_second_pass_quote($match[1], $match[2]);
+ },
)
);
break;
@@ -291,7 +304,9 @@ class bbcode
case 8:
$this->bbcode_cache[$bbcode_id] = array(
'preg' => array(
- '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#ise' => "\$this->bbcode_second_pass_code('\$1', '\$2')",
+ '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#is' => function ($match) {
+ return $this->bbcode_second_pass_code($match[1], $match[2]);
+ },
)
);
break;
@@ -301,7 +316,9 @@ class bbcode
'preg' => array(
'#(\[\/?(list|\*):[mou]?:?$uid\])[\n]{1}#' => "\$1",
'#(\[list=([^\[]+):$uid\])[\n]{1}#' => "\$1",
- '#\[list=([^\[]+):$uid\]#e' => "\$this->bbcode_list('\$1')",
+ '#\[list=([^\[]+):$uid\]#' => function ($match) {
+ return $this->bbcode_list($match[1]);
+ },
),
'str' => array(
'[list:$uid]' => $this->bbcode_tpl('ulist_open_default', $bbcode_id),