mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 20:13:22 +01:00
[ticket/13832] Use preg_replace_callback in bbcode class
PHPBB3-13832
This commit is contained in:
parent
a430fef05b
commit
3106195cdd
@ -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(?:="(.*?)")?:$uid\]((?!\[quote(?:=".*?")?:$uid\]).)?#ise' => "\$this->bbcode_second_pass_quote('\$1', '\$2')"
|
||||
'#\[quote(?:="(.*?)")?:$uid\]((?!\[quote(?:=".*?")?:$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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user