Skip to content

A glob class range spanning U+E000 matches every / and \: x[ア-z] matches "x/", and x[!ア-z] rejects it (gap in #157) #208

Open

Description

@matt-edmondson

What's wrong

Before DotNet.Glob sees a pattern or text, / and \ are both replaced with the private-use character U+E000 (MaskedPathSeparator, TextFilter/TextFilter.cs:453). #157 kept class ranges that span the real separators off the native path, but SpansPathSeparator (lines 745–746) only checks / and \, never U+E000 itself:

private static bool SpansPathSeparator(char first, char last) =>
    (first <= '/' && '/' <= last) || (first <= '\\' && '\\' <= last);

A letter range whose endpoints straddle U+E000 (e.g. katakana → full-width forms, or an IME slip like a-z) therefore goes to DotNet.Glob natively (IsNativeGlobRange, lines 741–743). In the masked text every separator is U+E000, which is inside the range. The listed path has the same gap: CollectGlobClassMembers (line ~769) enumerates U+E000 as a member, so a negated listed class excludes every separator.

Reproduction (run against 9699cc2, .NET 10)

Call (glob) Actual Expected
IsMatch("x/", "x[ア-z]") True False (U+002F is outside U+30A2–U+FF5A)
IsMatch("x/", "x[a-z]") True False
IsMatch("x\\", "x[a-z]") True False
IsMatch("x/", "x[!ア-z]") False True
IsMatch("x/", "x[0-9a-z]") True False (mixed class, native piece)
IsMatch("x/", "x[!0-9a-z]") False True (negated, listed)
control: IsMatch("x.", "x[ア-z]") / x[!ア-z] False / True correct

Filter example with items docs/, src/, readme.md, メモ.txt, メモ:

  • -*[ァ-z] ("hide names ending in katakana or full-width letters") gives readme.md, メモ.txt, wrongly hiding docs/ and src/
  • *[ァ-z] gives docs/, src/, メモ, wrongly including both directories

Why it matters

Ranges ending in the full-width/half-width forms block (U+FF00–U+FFEF) are ordinary for CJK users. Such a class silently matches, or under negation rejects, every path separator, so include and exclude filters disagree with the documented class semantics for any path-like item.

This is distinct from #194 (a literal U+E000 already in the text is read as a separator) and #175 (both separators share one mask). Remapping a literal U+E000 to another private-use character, as #194 suggests, would not fix this, because these ranges cover the whole private-use block.

Suggested fix / acceptance criteria

  1. SpansPathSeparator also returns true when first <= MaskedPathSeparator && MaskedPathSeparator <= last, so the range is listed rather than handed to DotNet.Glob natively
  2. CollectGlobClassMembers leaves out U+E000 unless / or \ is genuinely a member
  3. Tests for each row in the table above, including the [0-9a-z] / [!0-9a-z] mixed-class variants

Activity

  1. added
    bug
    on Nov 13, 2026
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