Skip to content

Let a glob class range start at a leading ] [patch] - #180

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/glob-class-range-from-leading-bracket
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/glob-class-range-from-leading-bracket

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

ToGlobCharacterList refused to start a range at a leading ], so []-a] was read as the set ], -, a. POSIX and fnmatch read it as the range ]..a, which is ] ^ _ a. The class missed ^, _and `` ``, and it matched -, which it shouldn't. `[!]-a]` was inverted the same way.

FindGlobClassEnd already starts looking for the closing bracket after a leading ], so the exception in the range check isn't needed. This PR removes it.

Tests

  • Two new rows in GlobClassMatchesEveryMemberOfEveryRange, run under both case sensitivities:
    • []-a] matches ] ^ _ aand rejects- b [`.
    • [!]-a] is the reverse.
  • The existing []a-] and [!]a-] rows, which end in a literal -, still pass.
  • With the fix reverted, both new rows fail. With the fix in, the full suite passes (215/215).

Overlap: #168 rewrites the doc comment directly above ToGlobCharacterList. This PR leaves that comment alone and explains the change in a comment on the line itself. I checked locally that this branch merges cleanly with every other open branch in the repo.

Fixes #179


Generated by Claude Code

ToGlobCharacterList refused to read a leading "]" as the start of a range,
so "[]-a]" became the set "]", "-", "a" instead of the range "]".."a",
missing "^", "_" and "`" and matching "-". FindGlobClassEnd already keeps a
leading "]" from closing the class, so the range check needs no exception.

Fixes #179

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW547mxaz1R4r27gAVm
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

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.

Glob class []-a] matches "-" but not "^" or "_": a range starting at a leading ] is read as three literals

2 participants