Repository navigation
Match an unclosed glob bracket literally [patch] - #165
Open
matt-edmondson wants to merge 2 commits into
Open
matt-edmondson wants to merge 2 commits into
matt-edmondson wants to merge 2 commits into
Conversation
DotNet.Glob reads a "[" with no closing "]" as a class running to the end of
the token, so "a[b" matched "ab" but not "a[b", and "-log[1" hid "log1" while
keeping "log[1". ExpandGlobClasses now writes such a bracket as the literal
"[[]", as fnmatch and bash treat it. A class left open after a dash
("file[0-") is still a range being typed, so it stays unparseable and is
ignored as DoesMatchGlob documents.
Fixes #159
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5Cza8WxR4s8ByZ2GX
|
This was referenced Oct 31, 2026
Glob class followed by a literal
] swallows it: *[[][0-9]] matches "items[3" but not "items[3]"
#172
Closed
matt-edmondson
pushed a commit
that referenced
this pull request
Nov 1, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5LUHQ94WSDTYRpSJV
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
* Match a literal ] straight after a glob class [patch] DotNet.Glob read a "]" that directly follows a closed bracket class as another member of that class, so "*[[][0-9]]" matched "items[3" and not "items[3]", and the excluded form let through what it was written to hide. ExpandGlobClasses now writes each such "]" as the one-member class "[]]", which DotNet.Glob reads as the literal the pattern means. Fixes #172 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5LUHQ94WSDTYRpSJV * Move the #172 tests away from the lines #158's and #165's tests add to Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5LUHQ94WSDTYRpSJV --------- Co-authored-by: Claude <noreply@anthropic.com>
Main added a row pinning the unclosed "x[^a" as unchanged. Under this branch an unclosed "[" is a literal, so the row now expects "x[[]^a". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3DwZv24u2tk7ZxTXk
Contributor
Author
|
The failing test is
No fix exists on --- a/TextFilter.Test/ReadmeTests.cs
+++ b/TextFilter.Test/ReadmeTests.cs
@@ using System.Collections.Generic;
+using System.ComponentModel;
using System.IO;
@@ public void EveryMethodInTheReadmeApiReferenceExistsWithItsDocumentedDefaults()
- MethodInfo[] overloads = [.. methods.Where(m => m.Name == methodName)];
+ MethodInfo[] overloads = [.. methods.Where(m => m.Name == methodName && m.GetCustomAttribute<EditorBrowsableAttribute>()?.State != EditorBrowsableState.Never)];I haven't added it to this PR, to keep this PR to #159. Once it lands on Generated by Claude Code |
This was referenced Nov 4, 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 #159
What was wrong
DotNet.Glob reads a
[that has no closing]as a character class running to the end of the token.ExpandGlobClassesreturned any token without a]unchanged, so a literal bracket silently became a class:log[1log1log[1a[baba[b-log[1log1, keptlog[1log[1, keepslog1log[,a[[]bChange
ExpandGlobClassesnow writes an unclosed[as the literal[[], the way fnmatch and bash treat it. This handles several brackets in one token and an unclosed bracket after a closed class ([ab]x[c→[ab]x[[]c).The
file[0-question: the issue asked for an explicit decision. I kept the documented #106/#110 behaviour: a class left open after a dash is a range still being typed, so it stays unparseable and is ignored. Two reasons:The
DoesMatchGlobremarks now describe both cases.Tests
GlobWithAnUnclosedBracketMatchesTheBracketLiterallyuses the issue's repro items. It checksIsMatch("a[b", "a[b")is true andIsMatch("ab", "a[b")is false, that-log[1excludeslog[1and keepslog1, and that the escaped form is unchanged. Each check runs case-sensitive and case-insensitive.ExpandGlobClassesRewritesOnlyClassesDotNetGlobMisreadsrows, plus one pinning thata[[]bis unchanged.file[0-,[!a-,-file[0-, …) still pass unchanged.Open PRs #162, #163 and #164 edit the same class rewriter, so whichever lands second may need a rebase.
Generated by Claude Code