Stop half-typed glob ranges from throwing - #108
Merged
Merged
Conversation
DotNet.Glob's tokeniser throws IndexOutOfRangeException on a range left
open after the dash ("file[0-"), which escaped IsMatch and Filter while a
user typed a range into a filter box. ResolveGlob now catches the parse
failure and caches a match-anything glob, the same way an invalid regex
pattern already degrades.
Fixes #106
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QPAgvLThqmty1U7AaebQMQ
|
This was referenced Sep 28, 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 #106
What was wrong
ResolveGlobcalledGlob.Parsewithout catching anything. DotNet.Glob's tokeniser throwsIndexOutOfRangeExceptionwhen a range is left open after the dash, and that exception escapedIsMatchandFilter. A filter box that re-filters on each keystroke crashes atfile[0-while the user typesfile[0-9].txt. The regex path doesn't have this problem, because it already turns an invalid pattern into match-anything.Change
ResolveGlobnow wraps the parse in a try/catch. On failure it caches a match-anything glob (*), so a bad pattern degrades the same way an invalid regex does and the exception isn't raised again on the next keystroke. The cache stays bounded as before.OutOfMemoryException, as triage suggested, so the next tokeniser bug is contained too.DoesMatchGlobremarks.I chose match-anything over treating the token literally because it matches the regex path, and because the list doesn't flash empty while someone is halfway through typing a range.
Tests
GlobWithAHalfTypedRangeDoesNotThrowcovers every throwing pattern listed in the issue (file[0-,[a-,a[b-,[!a-,*[0-,[a-]), through bothIsMatchandFilter, at both case sensitivities.TextFilter.cschange reverted, all 6 cases fail withSystem.IndexOutOfRangeException.dotnet test TextFilter.Test -c Release).I haven't filed the upstream DotNet.Glob report.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QPAgvLThqmty1U7AaebQMQ
Generated by Claude Code