Skip to content

A glob class with a large range plus anything else ("[가-힣a-z]*", "[一-龥0-9]*") matches every item, and as an exclusion ("-[一-龥a-z]*") hides nothing #184

Open

Description

@matt-edmondson

What's wrong

ToGlobCharacterList (TextFilter/TextFilter.cs, around line 608) flattens a class into an explicit character list. Once that list would exceed MaxGlobClassMembers (4096), it gives up and returns null.

ResolveGlob and DoesMatchGlob read null as "unparseable, ignore this token", the rule meant for half-typed tokens. A required token that is ignored matches everything, and an excluded one excludes nothing.

Repro (TextFilterMatchOptions.ByWholeString)

Call Observed Expected
IsMatch("README.md", "[가-힣a-z]*") True False
IsMatch("README.md", "[一-龥a-z]*") True False
IsMatch("README.md", "[一-龥0-9]*") True False
IsMatch("README.md", "-[一-龥a-z]*") True False (README.md should be excluded)
IsMatch("@", "[A-힣]") True False

The last case is a single range. It spans \, so since #157 it goes through the flattening path instead of DotNet.Glob.

Why it matters

CJK and Hangul ranges are the usual way to say "any Chinese or Korean character". Adding a-z or 0-9 to one silently turns the token into match-all, or for an exclusion, exclude-nothing. The XML docs only promise that incomplete, half-typed tokens are ignored, and this token is complete.

Suggested fix

Stop flattening large classes. Either of these works:

  • Split a multi-range class into one pattern per native range. ResolveGlob already returns a Glob[] and matches if any of them matches.
  • Translate the glob to a regex with a real character class.

At minimum, a class that is well-formed but too large should throw or be reported, not be read as "half-typed".

Acceptance: the five cases above give the expected results, and half-typed tokens like file[0- are still ignored (#141, #110).

Activity

  1. matt-edmondson commented on Nov 4, 2026

    @matt-edmondson
    ContributorAuthor

    Triage


    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

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions