Repository navigation
Ignore arbitrary values with unbalanced curly braces - #20766
Open
feliciovcm wants to merge 1 commit into
Open
feliciovcm wants to merge 1 commit into
feliciovcm wants to merge 1 commit into
Conversation
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.
Summary
Arbitrary values with a
{that is never closed are accepted and end up in the generated CSS:The
{opens a block, so rules that come after it are swallowed. Chromium parses.w-\[\{\] { width: {; } .underline { text-decoration-line: underline; }into a single rule, with.underlinenested inside it.Nested values like
w-[calc({)],bg-(--a,{)or[--a:{]are accepted too, and a nested}likew-[calc(})]generateswidth: calc(});.#20577 rejected unbalanced parens and brackets, but left
{off the stack so that a top-level}(e.g.[&{color:red}]:flex) stays invalid. This PR rejects a top-level{right away, which keeps that behavior, and tracks nested curlies on the stack so they have to be balanced. Balanced nested curlies likevar(--a,{})are still allowed.The Oxide scanner does not extract these candidates, so this affects callers that pass candidates to the JS compiler directly, e.g.
compile().build([…]).Test plan
Added cases to
candidate.test.ts. They fail without the fix (5 failures), and all pass with it:prettier --checkon the changed files andnode scripts/changelog.mjs checkpass.Output of
build(['w-[{]', 'underline']), before:After: