Skip to content

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

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

xiehuanyi wants to merge 2 commits into
fb55:masterfrom
xiehuanyi:fix/ascii-insensitive-attribute-comparison

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

[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 to equality, prefix, suffix, substring, word, and hyphen-prefix matching, including negated equality and implicit type matching.
    • Regex metacharacters in attribute values are matched literally by case-insensitive 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: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T21:11:45.237248Z bb3de07 New commits
ℹ️ 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

Explain Change →

No actionable comments were generated in the recent review.

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.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: nevandecoteau

Merge Risk: Minimal · up to bb3de

The ASCII-only matching change is mergeable after normal checks.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title accurately describes the change to ASCII-only case-insensitive attribute comparisons.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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 bright
ASCII cases settle right
Regex metacharacters stay
Non-ASCII keeps its own way
The selectors match by day

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: b05b19ba-0147-41e4-ad44-5e23517cbe7a
Commits

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

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; 3 remain after this review.

@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

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Limits case-insensitive attribute comparisons to ASCII letters.

  • Attribute selectors ignore case only for ASCII letters.

No actionable issues were found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "Merge latest master to resolve attribute..." · 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