mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge pull request #3618 from marc1706/ticket/13832
[ticket/13832] Use preg_replace_callback instead of /e modifier
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -214,7 +225,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;
|
||||
@@ -293,7 +306,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;
|
||||
@@ -303,7 +318,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),
|
||||
@@ -387,7 +404,9 @@ class bbcode
|
||||
}
|
||||
|
||||
// Replace {L_*} lang strings
|
||||
$bbcode_tpl = preg_replace('/{L_([A-Z0-9_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $bbcode_tpl);
|
||||
$bbcode_tpl = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($match) use ($user) {
|
||||
return (!empty($user->lang[$match[1]])) ? $user->lang($match[1]) : ucwords(strtolower(str_replace('_', ' ', $match[1])));
|
||||
}, $bbcode_tpl);
|
||||
|
||||
if (!empty($rowset[$bbcode_id]['second_pass_replace']))
|
||||
{
|
||||
@@ -511,7 +530,9 @@ class bbcode
|
||||
'email' => array('{EMAIL}' => '$1', '{DESCRIPTION}' => '$2')
|
||||
);
|
||||
|
||||
$tpl = preg_replace('/{L_([A-Z0-9_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl);
|
||||
$tpl = preg_replace_callback('/{L_([A-Z0-9_]+)}/', function ($match) use ($user) {
|
||||
return (!empty($user->lang[$match[1]])) ? $user->lang($match[1]) : ucwords(strtolower(str_replace('_', ' ', $match[1])));
|
||||
}, $tpl);
|
||||
|
||||
if (!empty($replacements[$tpl_name]))
|
||||
{
|
||||
|
Reference in New Issue
Block a user