Skip to content

Commit 7a6b629

Browse files
committed
Ensure that the input to chr() is between 0 and 255.
1 parent 409df40 commit 7a6b629

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

program/lib/Roundcube/rcube_utils.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,14 @@ public static function file2class($mimetype, $filename)
724724
public static function xss_entity_decode($content)
725725
{
726726
$callback = static function ($matches) {
727-
return chr(hexdec($matches[1]));
727+
$bytevalue = hexdec((string) $matches[1]);
728+
// chr() only covers values between 0 and 255. The following 4 lines are from the former default behaviour
729+
// to ensure that, which is now deprecated, so we now explicitly do the shifting here.
730+
while ($bytevalue < 0) {
731+
$bytevalue += 256;
732+
}
733+
$bytevalue %= 256;
734+
return chr($bytevalue);
728735
};
729736

730737
$out = html_entity_decode(html_entity_decode($content));

0 commit comments

Comments
 (0)