Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ public static function parseList(ParserState $parserState, CSSList $list): void
$listItem = null;
if ($usesLenientParsing) {
try {
$positionBeforeParse = $parserState->currentColumn();
$listItem = self::parseListItem($parserState, $list);
} catch (UnexpectedTokenException $e) {
$listItem = false;
// If the failed parsing did not consume anything that was to come ...
if ($parserState->currentColumn() === $positionBeforeParse && !$parserState->isEnd()) {
// ... the unexpected token needs to be skipped, otherwise there'll be an infinite loop.
$parserState->consume(1);
}
}
} else {
$listItem = self::parseListItem($parserState, $list);
Expand Down
4 changes: 4 additions & 0 deletions src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ public function parseCharacter(bool $isForIdentifier): ?string
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*
* @phpstan-impure
* This method may change the state of the object by advancing the internal position;
* it does not simply 'get' a value.
*/
public function consumeWhiteSpace(): array
{
Expand Down