mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 20:16:45 +00:00
Fixed JS escaping for unicode characters with higher code points
This commit is contained in:
committed by
Fabien Potencier
parent
c5ba65ca44
commit
7f9134952d
@@ -1,6 +1,6 @@
|
||||
* 1.32.1 (2017-XX-XX)
|
||||
|
||||
* n/a
|
||||
* fixed JS escaping for unicode characters with higher code points
|
||||
|
||||
* 1.32.0 (2017-02-26)
|
||||
|
||||
|
||||
@@ -1168,8 +1168,13 @@ function _twig_escape_js_callback($matches)
|
||||
|
||||
// \uHHHH
|
||||
$char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
|
||||
$char = strtoupper(bin2hex($char));
|
||||
|
||||
return '\\u'.strtoupper(substr('0000'.bin2hex($char), -4));
|
||||
if (4 >= strlen($char)) {
|
||||
return sprintf('\u%04s', $char);
|
||||
}
|
||||
|
||||
return sprintf('\u%04s\u%04s', substr($char, 0, -4), substr($char, -4));
|
||||
}
|
||||
|
||||
function _twig_escape_css_callback($matches)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
--TEST--
|
||||
"escape" filter
|
||||
--TEMPLATE--
|
||||
{{ "é ♜ 𝌆"|e('js') }}
|
||||
--DATA--
|
||||
return array()
|
||||
--EXPECT--
|
||||
\u00E9\x20\u265C\x20\uD834\uDF06
|
||||
Reference in New Issue
Block a user