Skip to content

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

Closed

Description

@matt-edmondson

What's wrong

DotNet.Glob 3.1.3 (pinned in Directory.Packages.props) turns a bracket class into exactly one token, of one of two kinds:

  • A single range (LetterRangeToken / NumberRangeToken). Everything after the first range is ignored.
  • A plain character list (CharacterListToken). Here - is just another member, and no ranges are read.

It never combines a range with other members. ResolveGlob (TextFilter/TextFilter.cs, ~L521-547) passes the tokens straight through and does nothing to make up for this. Nothing throws, so these patterns are not "unparseable and ignored". They just give wrong answers:

Pattern DotNet.Glob reads it as Consequence
[0-9a-f] number range 0-9 c doesn't match
[a-zA-Z] letter range a-z Q doesn't match (case-sensitive)
[a-z_] letter range a-z _ doesn't match
[-0-9] list -, 0, 9 5 doesn't match
[ab-d] list a, b, -, d c doesn't match

Repro (verified with tests through TextFilter.IsMatch, TextFilterType.Glob, ByWholeString)

failed HexClass          Assert.IsTrue(IsMatch("c", "[0-9a-f]"))
failed AlphaClass        Assert.IsTrue(IsMatch("Q", "[a-zA-Z]"))   // case-sensitive
failed UnderscoreClass   Assert.IsTrue(IsMatch("_", "[a-z_]"))

Why it matters

Hex digits, both letter cases and identifier characters are among the most common things people put in a class. A user filtering with *[0-9a-f] or [a-zA-Z]* gets items silently hidden, with no error and no sign the pattern was misread.

Suggested fix / acceptance criteria

Doing this would also make the dash's position in a class irrelevant, which resolves the trailing-dash regression filed alongside this issue.

Activity

  1. added
    bug
    on Oct 20, 2026
  2. matt-edmondson commented on Oct 23, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    Notes: Very common classes ([0-9a-f], [a-zA-Z], [a-z_]) give wrong results with no error, so users lose matches without knowing it. Expanding range-bearing classes into explicit character lists, with a cap on expansion size, is the smaller fix. Translating to Regex is larger but also covers the timeout protection #131 asks for. Pick one and land it together with #153.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions