Skip to content

Match a path separator inside a glob class range that spans it [patch] - #164

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/157-class-range-spanning-separator
Oct 31, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/157-class-range-spanning-separator

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #157

Summary

MaskPathSeparators swaps / and \ for U+E000 in both the pattern and the text. A class range covers a separator only through its endpoints, so masking never reaches it, and a native range like [A-z] never contained the masked \ in the text. The negated [!A-z] therefore selected the very characters it was meant to exclude.

Since #156, ResolveGlob already runs ExpandGlobClasses before masking. Mixed classes such as [.-0] (. and 0 are not both letters or both digits) were already expanded into a list, and its / gets masked, so those rows of the issue's table already pass on main. The rows still failing were the single letter range that IsNativeGlobRange hands to DotNet.Glob unchanged, [A-z] / [!A-z].

IsNativeGlobRange now refuses a range that spans / (U+002F) or \ (U+005C). Such a range goes through ToGlobCharacterList, and the separator it contains is masked like any literal one. A letter range only spans \ when it runs from uppercase into lowercase, and digit ranges never span either separator, so the common [a-z], [A-Z] and [0-9] stay native.

A letter range that spans \ and also covers more than MaxGlobClassMembers (4096) characters, say [A-z], now comes back unparseable instead of matching with a missing \. That's the same limit any mixed class already has.

Not in scope

/ and \ share one mask (#132), so a class containing one also matches the other. The new tests don't try to tell them apart, and say so.

Tests

  • GlobClassRangeSpanningAPathSeparatorMatchesIt covers each row of the issue's table, including the negated forms, plus [*-0] and a native [a-z] control.
  • ExpandGlobClassesRewritesOnlyClassesDotNetGlobMisreads: [!A-z] is now listed, and [A-Z] stays native.
  • With the TextFilter.cs change reverted, 3 cases fail ([A-z] and [!A-z] against \, plus the expansion row). With the change, the full suite passes: 209/209 (dotnet test, net10.0, Linux).

This branches from main independently of #163 (#158). The two touch neighbouring helpers but different lines.


Generated by Claude Code

matt-edmondson and others added 2 commits October 30, 2026 03:31
Path separators are masked to a private-use character before DotNet.Glob
sees the pattern or the text, so a letter range left for it to match
natively, such as [A-z], never contained the masked \. A range that spans
/ or \ is now expanded into a character list, whose separator gets masked
like any literal one.

Fixes #157

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

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 55d4d13 into main Oct 31, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/157-class-range-spanning-separator branch October 31, 2026 03:29
matt-edmondson added a commit that referenced this pull request Oct 31, 2026
Resolve the IsNativeGlobRange conflict with #164: a lone range stays
native only when its endpoints share a case or are both digits, and it
does not span a path separator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5pNp5mLi7vkHCEABR
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 range spanning / or \ doesn't match it, and the negated class does: [.-0] misses "/", [!A-z] matches "\"

1 participant