Repository navigation
Mask / and \ to different characters in glob matching [patch] - #175
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
Both separators were masked to U+E000, so after masking a glob could not tell them apart: "1/2" also matched "1\2", and "-*/*" excluded Windows paths along with URLs. "\" now masks to U+E001, and a "**" segment keeps the separator the pattern wrote. Fixes #132 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2nwQnKNnZqSnbuUxe
|
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 #132
What was wrong
The #114 fix masks path separators so that DotNet.Glob treats them as ordinary characters. It masked both
/and\toU+E000, so after masking the glob could no longer tell them apart:1/2matched1\2.-*/*hidC:\tempalong with URLs.Change
\is now masked toU+E001, and/staysU+E000. The same masking applies to the pattern and the text.ExpandGlobStarSegmentsused to look for**followed by the single mask. It now accepts either mask, and when it keeps the*<sep>form, that form ends at the separator the pattern wrote.Behaviour change: a
**segment no longer crosses into the other separator kind.src/**/*.csdoesn't matchsrc\x\a.cs, andsrc\**\*.csdoesn't matchsrc/x/a.cs. That follows from the issue's rule that the two characters are different. A single*or?still crosses either separator, as #114 requires.This edits
ExpandGlobStarSegments, which open PR #171 also touches, so whichever lands second may need a small rebase.Tests
GlobTellsSlashAndBackslashApartcovers the issue's three cases in both directions, under both sensitivities. It also checks that*and?still cross either separator.GlobStarSegmentEndsAtTheSeparatorThePatternWrotecovers the mixed-separator**case above.GlobClassRangeSpanningAPathSeparatorMatchesIt(Glob class range spanning / or \ doesn't match it, and the negated class does:[.-0]misses "/",[!A-z]matches "\" #157) now separates the two characters. Its comment said its rows couldn't, because of this issue.[*-0]previously listed\as matching, which only held because of the shared mask:\(0x5C) is outside*–0.\masked back toU+E000, 9 tests fail. With the fix, the full suite passes on net10.0: 217/217.Generated by Claude Code