Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/Value/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,19 @@ public static function parsePrimitiveValue(ParserState $parserState)
} elseif ($parserState->comes('U+')) {
$value = self::parseUnicodeRangeValue($parserState);
} else {
$sNextChar = $parserState->peek(1);
$nextCharacter = $parserState->peek(1);
try {
$value = self::parseIdentifierOrFunction($parserState);
} catch (UnexpectedTokenException $e) {
if (\in_array($sNextChar, ['+', '-', '*', '/'], true)) {
if (\in_array($nextCharacter, ['+', '-', '*', '/'], true)) {
$value = $parserState->consume(1);
} else {
throw $e;
}
}
}
$parserState->consumeWhiteSpace();

return $value;
}

Expand All @@ -204,16 +205,17 @@ private static function parseMicrosoftFilter(ParserState $parserState): CSSFunct
*/
private static function parseUnicodeRangeValue(ParserState $parserState): string
{
$iCodepointMaxLength = 6; // Code points outside BMP can use up to six digits
$sRange = '';
$codepointMaxLength = 6; // Code points outside BMP can use up to six digits
$range = '';
$parserState->consume('U+');
do {
if ($parserState->comes('-')) {
$iCodepointMaxLength = 13; // Max length is 2 six-digit code points + the dash(-) between them
$codepointMaxLength = 13; // Max length is 2 six-digit code points + the dash(-) between them
}
$sRange .= $parserState->consume(1);
} while (\strlen($sRange) < $iCodepointMaxLength && \preg_match('/[A-Fa-f0-9\\?-]/', $parserState->peek()));
return "U+{$sRange}";
$range .= $parserState->consume(1);
} while (\strlen($range) < $codepointMaxLength && \preg_match('/[A-Fa-f0-9\\?-]/', $parserState->peek()));

return "U+{$range}";
}

/**
Expand Down