Repository navigation
Match every member of a glob class that mixes a range with other characters [patch] - #156
Merged
Merged
Conversation
…acters [patch] DotNet.Glob reads a bracket class as a single range or a plain character list, never both, so [0-9a-f] missed "c", [a-zA-Z] missed "Q" and [a-z_] missed "_". Moving a trailing dash to the front (6937eb9) also pushed classes it read correctly, such as [a-z-] and file[0-9a-], into list mode, and turned []a-] into a pattern that matched nothing. Each closed class DotNet.Glob would misread is now rewritten into the explicit character list it means, keeping negation, with "]" first, "-" next and "!" never first. A lone letter or digit range is left for DotNet.Glob to match natively. A class whose ranges span more than 4096 characters, or that has no members, is treated as unparseable. Fixes #152 Fixes #153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4bHjeyXzXRGQc26aV
…ognitive complexity Addresses SonarCloud S3776 on ExpandGlobClasses (18 against a limit of 15). No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4bHjeyXzXRGQc26aV
|
This was referenced Oct 29, 2026
Closed
This was referenced Oct 30, 2026
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 #152
Fixes #153
What was wrong
DotNet.Glob 3.1.3 reads a bracket class as one token: a single range when the class starts
x-ywith two letters or two digits, or otherwise a plain character list where-is a member and no ranges are read. It never combines them, so:[0-9a-f]missedc,[a-zA-Z]missedQ,[a-z_]missed_,[-0-9]missed5,[ab-d]missedc(Glob character classes that combine a range with anything else silently drop members: [0-9a-f] doesn't match "c", [a-zA-Z] doesn't match "Q", [a-z_] doesn't match "_" #152)MoveTrailingClassDashes(6937eb9) moved a trailing dash to the front of every class, which pushed[a-z-]andfile[0-9a-]into list mode and turned[]a-]into[-]a], which matches nothing (Since the trailing-dash fix (6937eb9), [a-z-] no longer matches "q", file[0-9a-] no longer matches "file5", and []a-] matches nothing #153)The fix
MoveTrailingClassDashesis replaced byExpandGlobClasses. It rewrites every closed class DotNet.Glob would misread into the explicit character list it means, using the usual glob rules: a leading]and a leading or trailing-are literal, andx-yis an inclusive range. Negation is kept. The list is written in an order DotNet.Glob reads as a plain list:]first, then-, and!never first. So[0-9a-f]becomes[0123456789abcdef],[a-z-]becomes[-abc…z], and[]a-]becomes[]-a].[a-z],[!0-9],[一-龥]) is left for DotNet.Glob to match natively. It already reads that form correctly, and it may cover far more characters than are worth listing.-is left unchanged.file[0-.I verified the list and range behaviour against DotNet.Glob 3.1.3 directly before writing the ordering rules.
Tests
ExpandGlobClassesRewritesOnlyClassesDotNetGlobMisreadsandExpandGlobClassesRejectsClassesThatCannotBeListed.IsMatch(Glob,ByWholeString), each case-sensitive and case-insensitive. They cover[0-9a-f],[!0-9a-f],[a-z_],[-0-9],[ab-d],[a-z-],file[0-9a-],[]a-],[!]a-],[!-#], and[a-zA-Z]matching both cases.main's implementation and all pass with this change. The full suite passes: 189/189.Generated by Claude Code