Skip to content

Commit 37f0bad

Browse files
committed
Tighter loop constraints when parsing unicode-range
1 parent 29c1d84 commit 37f0bad

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,14 @@ private function parseLineNameValue() {
508508
}
509509

510510
private function parseUnicodeRangeValue() {
511+
$iCodepointMaxLenth = 6; // Code points outside BMP can use up to six digits
511512
$sRange = "";
513+
$this->consume("U+");
512514
do {
515+
if ($this->comes('-')) $iCodepointMaxLenth = 13; // Max length is 2 six digit code points + the dash(-) between them
513516
$sRange .= $this->consume(1);
514-
} while (!$this->comes(',') && !$this->comes(';') && !$this->comes('}'));
515-
return $sRange;
517+
} while (strlen($sRange) < $iCodepointMaxLenth && preg_match("/[A-Fa-f0-9\?-]/", $this->peek()));
518+
return "U+{$sRange}";
516519
}
517520

518521
private function parseColorValue() {

0 commit comments

Comments
 (0)