What's wrong
ResolveGlob (TextFilter/TextFilter.cs:~399-408) calls Glob.Parse with no exception handling. DotNet.Glob's tokenizer (GlobTokeniser.ReadRangeOrListToken) throws IndexOutOfRangeException when a range is left open after the dash. That exception escapes from IsMatch and Filter.
The regex path doesn't behave this way: it turns an invalid pattern into match-anything. The glob path has no equivalent fallback.
Failure scenario (verified with a temporary MSTest)
Take a filter box that re-filters on each keystroke. While the user is typing file[0-9].txt, the intermediate text file[0- reaches this call:
TextFilter.Filter(["file1.txt"], "file[0-"); // IndexOutOfRangeException
Patterns that throw:
Other malformed patterns don't throw; they just return false: [a-z, [, [!, {, [], a\.
Suggested fix
Wrap Glob.Parse in ResolveGlob in a try/catch. On failure, degrade the same way the regex path does:
- cache a match-anything glob (
*), or a glob that treats the token literally;
- keep the cache bounded, as it is now.
It may also be worth reporting the tokenizer crash upstream to DotNet.Glob.
Acceptance: IsMatch and Filter never throw for any of the patterns listed above, and a test pins down that behaviour.
What's wrong
ResolveGlob(TextFilter/TextFilter.cs:~399-408) callsGlob.Parsewith no exception handling. DotNet.Glob's tokenizer (GlobTokeniser.ReadRangeOrListToken) throwsIndexOutOfRangeExceptionwhen a range is left open after the dash. That exception escapes fromIsMatchandFilter.The regex path doesn't behave this way: it turns an invalid pattern into match-anything. The glob path has no equivalent fallback.
Failure scenario (verified with a temporary MSTest)
Take a filter box that re-filters on each keystroke. While the user is typing
file[0-9].txt, the intermediate textfile[0-reaches this call:Patterns that throw:
[a-a[b-[!a-*[0-[a-]Other malformed patterns don't throw; they just return false:
[a-z,[,[!,{,[],a\.Suggested fix
Wrap
Glob.ParseinResolveGlobin a try/catch. On failure, degrade the same way the regex path does:*), or a glob that treats the token literally;It may also be worth reporting the tokenizer crash upstream to DotNet.Glob.
Acceptance:
IsMatchandFilternever throw for any of the patterns listed above, and a test pins down that behaviour.