fix: [#2034] QuerySelector fails to match attribute values containing quotes#2036
Closed
JalilArfaoui wants to merge 1 commit into
Closed
fix: [#2034] QuerySelector fails to match attribute values containing quotes#2036JalilArfaoui wants to merge 1 commit into
JalilArfaoui wants to merge 1 commit into
Conversation
… quotes When using querySelector with an attribute selector, values containing apostrophes in double-quoted selectors (or double quotes in single-quoted selectors) were not matched correctly. For example, [data-value="it's a test"] would fail to find elements with that attribute value. The issue was in the regex that captures attribute values: it excluded both quote types regardless of which delimiter was used. The fix uses lookbehind/lookahead assertions to correctly match the value based on the actual delimiter used.
63c9ea1 to
9a0eec3
Compare
Contributor
|
This should be addressed by #2010, which replaces the custom CSS selector parser completely. I've added your test cases to that PR to confirm. |
Owner
|
Thank you for contributing @JalilArfaoui ⭐ I believe this was fixed by #2068, so I will close this now. |
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.
Fixes #2034
Root cause
The regex that captures attribute values used [^"']* which excludes both quote types regardless of which delimiter is actually used:
Fix
Use lookbehind/lookahead assertions to match the value based on the actual delimiter:
This captures the value correctly without adding any new capture groups.
Test plan