Repository navigation
Ignore quoted attribute values in the selector safety checks - #4
Merged
Merged
Conversation
checkSelectorSafety() looked for pseudo-classes and counted brackets
across the whole selector, including inside quoted attribute values.
Valid rules were rejected:
- div[class*="md:hidden"] (a Tailwind class) and
[data-state="modal:open"]: "The pseudo-class ":hidden" is not allowed."
- [title='Disable adblock :('] and [data-x="a[b"]: "Selector has
unbalanced brackets."
Quoted values are now blanked out before the bracket and pseudo-class
checks. Backslashes are already disallowed, so a quote cannot be
escaped; a quote left unclosed ([data-x="a].b), which was accepted
before, is now rejected with its own reason. Pseudo-classes and
pseudo-elements outside quotes are rejected as before.
Co-authored-by: Claude <noreply@anthropic.com>
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.
checkSelectorSafety()looked for pseudo-classes and counted brackets across the whole selector, including inside quoted attribute values. Valid rules from the dashboard or a rules import were rejected:div[class*="md:hidden"](a Tailwind class):hiddenis not allowed."[data-state="modal:open"]:openis not allowed."[title='Disable adblock :('][data-x="a[b"]Fix: quoted values are blanked out before the bracket and pseudo-class checks. Backslashes are already disallowed, so a quote can't be escaped. An unclosed quote such as
[data-x="a].b, which was accepted before, is now rejected with its own reason. Pseudo-classes and pseudo-elements outside quotes are rejected as before.Tests: in
tests/unit/selector.test.ts, the four selectors above now pass. Rejected::hoverand::beforeafter a quoted value (unchanged behavior), and the unterminated quote (new). The 5 changed expectations fail onmain. Typecheck, lint and Prettier are clean.npm test: 219 passed.Co-authored-by: Claude noreply@anthropic.com