Skip to content

Commit ad21c3d

Browse files
committed
Don't consume character after , without checking
Also remove fix for `consumeUntil` bug, which #1320 will address.
1 parent 4df6b74 commit ad21c3d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Parsing/ParserState.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,6 @@ public function consumeUntil(
345345
$start = $this->currentPosition;
346346

347347
while (!$this->isEnd()) {
348-
$comment = $this->consumeComment();
349-
if ($comment instanceof Comment) {
350-
$comments[] = $comment;
351-
}
352348
$character = $this->consume(1);
353349
if (\in_array($character, $stopCharacters, true)) {
354350
if ($includeEnd) {

src/RuleSet/DeclarationBlock.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,19 @@ public static function parse(ParserState $parserState, ?CSSList $list = null): ?
4444
$selectorParts = [];
4545
$stringWrapperCharacter = null;
4646
$functionNestingLevel = 0;
47+
$consumedNextCharacter = false;
4748
do {
48-
$selectorParts[] = $parserState->consume(1)
49-
. $parserState->consumeUntil(['{', '}', '\'', '"', '(', ')', ','], false, false, $comments);
49+
if (!$consumedNextCharacter) {
50+
$selectorParts[] = $parserState->consume(1);
51+
}
52+
$selectorParts[] = $parserState->consumeUntil(
53+
['{', '}', '\'', '"', '(', ')', ','],
54+
false,
55+
false,
56+
$comments
57+
);
5058
$nextCharacter = $parserState->peek();
59+
$consumedNextCharacter = false;
5160
switch ($nextCharacter) {
5261
case '\'':
5362
// The fallthrough is intentional.
@@ -78,6 +87,7 @@ public static function parse(ParserState $parserState, ?CSSList $list = null): ?
7887
$selectors[] = \implode('', $selectorParts);
7988
$selectorParts = [];
8089
$parserState->consume(1);
90+
$consumedNextCharacter = true;
8191
}
8292
break;
8393
}

0 commit comments

Comments
 (0)