Skip to content

Commit 268d0a5

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: [Console]Improve formatter for double-width character Lower mbstring dep, remove it for Yaml and CssSelector components [Security] Add check for supported attributes in AclVoter [Form] Fixed TrimListenerTest as of PHP 5.5 Added more IDE links [DependencyInjection] Fix parameter description in ConfigurationExtensionInterface [Finder] fixed typehint of the Finder::addAdapter() method [TwigBridge][Transchoice] set %count% from the current context. [DependencyInjection] Fix travis unit tests Update PHPUnit before run [Validator] fixed wrong test [WebProfilerBundle] added test case for #10773 [WebProfilerBundle] fixed profiler homepage, fixed #10806 [WebProfilerBundle] Added test case for #10806 changed travis to run on the nightly builds of HHVM until everything gets stable Fixed issue #5427 Allow URLs that don't contain a path Conflicts: .travis.yml
2 parents 479a5b4 + 2ff53e8 commit 268d0a5

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Parser/Tokenizer/TokenizerEscaping.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,18 @@ public function escapeUnicodeAndNewLine($value)
6565
*/
6666
private function replaceUnicodeSequences($value)
6767
{
68-
return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function (array $match) {
69-
$code = $match[1];
68+
return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function ($match) {
69+
$c = hexdec($match[1]);
7070

71-
if (bin2hex($code) > 0xFFFD) {
72-
$code = '\\FFFD';
71+
if (0x80 > $c %= 0x200000) {
72+
return chr($c);
73+
}
74+
if (0x800 > $c) {
75+
return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F);
76+
}
77+
if (0x10000 > $c) {
78+
return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F);
7379
}
74-
75-
return mb_convert_encoding(pack('H*', $code), 'UTF-8', 'UCS-2BE');
7680
}, $value);
7781
}
7882
}

0 commit comments

Comments
 (0)