mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/10388] Use TWIG escape JS filter instead of addslashes
PHPBB3-10388
This commit is contained in:
parent
fc412a97ca
commit
a62adfc115
2 changed files with 5 additions and 5 deletions
|
@ -71,7 +71,7 @@ class extension extends \Twig_Extension
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)),
|
new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)),
|
||||||
new \Twig_SimpleFilter('addslashes', 'addslashes'),
|
new \Twig_SimpleFilter('addslashes', 'addslashes'), // Deprecate addslashes in phpBB 3.1.4
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ class extension extends \Twig_Extension
|
||||||
return $context_vars['L_' . $key];
|
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
|
// need to check for it
|
||||||
|
|
||||||
return call_user_func_array(array($this->user, 'lang'), $args);
|
return call_user_func_array(array($this->user, 'lang'), $args);
|
||||||
|
|
|
@ -117,9 +117,9 @@ class lexer extends \Twig_Lexer
|
||||||
// Appends any filters after lang()
|
// Appends any filters after lang()
|
||||||
$code = preg_replace('#{L_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2 }}', $code);
|
$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 }}
|
// Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|escape('js') }}
|
||||||
// Appends any filters after lang(), but before addslashes
|
// Appends any filters after lang(), but before escape('js')
|
||||||
$code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2|addslashes }}', $code);
|
$code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2|escape(\'js\') }}', $code);
|
||||||
|
|
||||||
// Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }}
|
// Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }}
|
||||||
// Appends any filters
|
// Appends any filters
|
||||||
|
|
Loading…
Add table
Reference in a new issue