Repository navigation
CSS: a stray closing token no longer drops the level below zero - #136
Merged
Merged
Conversation
parseDeclarationError and parseAtRuleUnknown decremented the nesting level on every ')', ']' or '}',
also on one without its opening token. The level went below zero, so the ';' or '}' that should
end the bad declaration or the at-rule no longer did, and everything after it was swallowed:
"color:red);display:none" lost display:none, and ".foo{color:red);display:none}.bar{color:red}"
lost the rest of the stylesheet. A closing token now lowers the level only when one is open.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Well spotted, thanks for the fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A closing token without its opening one (a stray
),]or}) took the parser's nesting level below zero in two places, and nothing after it closed again:parseDeclarationError: the offending)of an "unexpected ending in declaration" error is popped again in the recovery loop and decremented the level to -1, so the;that should end the bad declaration no longer did.color:red);display:none(inline) lostdisplay:none..foo { color:red); display:none } .bar { color:red; }lost the rest of the stylesheet, since the}at level -1 did not end the rule either.parseAtRuleUnknown:@foo { a) } .bar { color:red; }kept the}and.bar { color:red; }as tokens of the unknown at-rule.Per CSS Syntax, a stray closing token is an ordinary token: the bad declaration ends at the next
;and the block at its}. The fix lowers the level only when one is open. The other decrements already guard against this (p.level == 0is handled before them).Tests: four cases in
TestParse, failing before the change;go test ./...passes.🤖 Generated with Claude Code