Skip to content

fix(attributes): limit insensitive comparisons to ASCII - #1912

Open
xiehuanyi wants to merge 1 commit into
fb55:masterfrom
xiehuanyi:fix/ascii-insensitive-attribute-comparison
Open

xiehuanyi wants to merge 1 commit into
fb55:masterfrom
xiehuanyi:fix/ascii-insensitive-attribute-comparison

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 12, 2026 •

Copy link
Copy Markdown

[data-foo="ä" i] currently matches data-foo="Ä". The same non-ASCII folding affects all insensitive comparison operators and attributes whose default comparison is insensitive. Selectors require ASCII case-insensitive comparison, so these distinct non-ASCII characters must remain distinct.

Restrict folding to A–Z in string comparisons. Build explicit ASCII character pairs for regex-based comparisons instead of using JavaScript's Unicode-aware i flag. Regex metacharacters remain escaped. Existing ASCII-insensitive behavior is retained.

Validation: eight new cases fail before the fix. npm test passes 226 tests with one existing skipped test, including ESLint, TypeScript and Biome. Tests cover all operators, implicit HTML attribute comparison, exact non-ASCII matches, and literal regex characters. npm run build and git diff --check pass.

Prepared and tested with OpenAI Codex assistance.

View guided diff

Summary by CodeRabbit

  • Bug Fixes
    • Case-insensitive attribute selectors now match ASCII letters without treating non-ASCII uppercase and lowercase characters as equivalent. This applies across equality, prefix, suffix, substring, word, and hyphen-prefix matching, including negated equality and implicit type matching.
    • Attribute values containing regex metacharacters are now matched literally by substring and word selectors. Case-sensitive matching remains unchanged.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T19:15:24.664871Z 258df45 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1d772c49-a57a-42d6-8239-f2ea1cea47cb

📥 Commits

Reviewing files that changed from the base of the PR and between 94edb4b and 258df45.


📒 Files selected for processing (2)
  • src/attributes.ts
  • test/attributes.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.



📝 Walkthrough

Walkthrough

Case-insensitive attribute selector matching now folds ASCII uppercase letters only. Equality, hyphen, word, prefix, suffix, substring, and negated-equality selectors use this behavior. Tests cover non-ASCII distinctions, implicit type matching, and literal regex characters.

Changes

Attribute selector matching

Layer / File(s) Summary
ASCII case-insensitive matching
src/attributes.ts, test/attributes.ts
Case-insensitive selectors now fold ASCII letters only. Word and substring selectors use escaped patterns with explicit ASCII case alternatives. Tests check non-ASCII distinctions, implicit type matching, and literal regex characters.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix


Merge Risk: ⚪ Minimal · up to 258df

The change aims to preserve ASCII-insensitive matching while distinguishing non-ASCII attribute values. No concrete merge-blocking risk is established by the available evidence.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: limiting case-insensitive attribute comparisons to ASCII.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each letter’s case
And keeps non-ASCII in its place
Escaped stars stay literal
Tests make the rules clear
Then hops away with ears held high

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Restricts insensitive attribute comparisons to ASCII letters.

  • Insensitive attribute selectors now fold only ASCII letters.

Reviews (1) · Last reviewed commit: "fix(attributes): limit insensitive compa..." · Reviewed by Greptile

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants