mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-07 01:06:48 +02:00
Merge pull request #3352 from VSEphpbb/ticket/10388
Ticket/10388 Use Twig's JS escape filter instead of addslashes on LA_ keys
This commit is contained in:
@@ -71,6 +71,7 @@ class extension extends \Twig_Extension
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)),
|
||||
// @deprecated 3.2.0 Uses twig's JS escape method instead of addslashes
|
||||
new \Twig_SimpleFilter('addslashes', 'addslashes'),
|
||||
);
|
||||
}
|
||||
@@ -177,7 +178,7 @@ class extension extends \Twig_Extension
|
||||
return $context_vars['L_' . $key];
|
||||
}
|
||||
|
||||
// LA_ is transformed into lang(\'$1\')|addslashes, so we should not
|
||||
// LA_ is transformed into lang(\'$1\')|escape('js'), so we should not
|
||||
// need to check for it
|
||||
|
||||
return call_user_func_array(array($this->user, 'lang'), $args);
|
||||
|
@@ -117,9 +117,9 @@ class lexer extends \Twig_Lexer
|
||||
// Appends any filters after lang()
|
||||
$code = preg_replace('#{L_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2 }}', $code);
|
||||
|
||||
// Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|addslashes }}
|
||||
// Appends any filters after lang(), but before addslashes
|
||||
$code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2|addslashes }}', $code);
|
||||
// Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|escape('js') }}
|
||||
// Appends any filters after lang(), but before escape('js')
|
||||
$code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2|escape(\'js\') }}', $code);
|
||||
|
||||
// Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }}
|
||||
// Appends any filters
|
||||
|
Reference in New Issue
Block a user