From 71f5c9c32715b634d315f79aa11df07be2a9676c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 18 May 2015 17:07:02 +0200 Subject: [PATCH] [ticket/13832] Use preg_replace_callback instead of /e modifier PHPBB3-13832 --- phpBB/includes/acp/acp_bbcodes.php | 4 +++- phpBB/includes/bbcode.php | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index d451b4d899..9c00e89713 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -491,7 +491,9 @@ class acp_bbcodes if (preg_match_all('/(?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) { + if (!empty($user->lang[$match['1']])) + { + return $user->lang[$match['1']]; + } + else + { + return ucwords(strtolower(str_replace('_', ' ', $match['1']))); + } + }, $bbcode_tpl); if (!empty($rowset[$bbcode_id]['second_pass_replace'])) { @@ -509,7 +518,16 @@ 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) { + if (!empty($user->lang[$match['1']])) + { + return $user->lang[$match['1']]; + } + else + { + return ucwords(strtolower(str_replace('_', ' ', $match['1']))); + } + }, $tpl); if (!empty($replacements[$tpl_name])) {