Skip to content

find - [:digit:] in a glob matches every Unicode decimal digit, not just 0-9 #958

Closed

Description

@sylvestre

Known: #864 (open PR) — #864 (related: the fancy-regex rewrite maps [:digit:] to 0-9 as a side effect; not a fix aimed at this bug)

POSIX limits [:digit:] to 0-9 in every locale. In the globs of -name, -path,
-lname and their -i forms, uutils find hands the class to Oniguruma, which uses its
Unicode tables. As a result, [[:digit:]] also matches fullwidth 1 (U+FF11), Arabic-Indic
١ (U+0661) and about 750 other code points. -name '*[![:digit:]]*' therefore skips names
that GNU find lists.

Reproduction

$ mkdir d && cd d && touch 123 12a plain.txt $'123'     # last one is "123"

Rust (incorrect)

$ LC_ALL=C ./target/release/find . -type f -name '[[:digit:]]*' | sort
./123
./12a
./123
# Exit code: 0

(the same output with LC_ALL=C.UTF-8)

GNU (correct)

$ LC_ALL=C /usr/bin/find . -type f -name '[[:digit:]]*' | sort
./123
./12a
# Exit code: 0

(the same output with LC_ALL=C.UTF-8)

Root cause

extract_bracket_expr() in src/find/matchers/glob.rs:84-91 copies [:...:] classes into
the regex unchanged:

if matches!(delim, '.' | '=' | ':') {
    let rest = chars.as_str();
    let closer = format!("{delim}]");
    let end = rest.find(closer.as_str())? + 2;
    expr.push_str(&rest[..end]);
    ...

parse_bre() (glob.rs:10-13) then compiles the result as UTF-8. The onig crate does not
expose ONIG_OPTION_DIGIT_IS_ASCII, so the Unicode digit table is used.

Test

In the mod tests of src/find/matchers/glob.rs:

#[rstest]
#[case("7", true)]
#[case("\u{ff17}", false)]   // FULLWIDTH DIGIT SEVEN
#[case("\u{0667}", false)]   // ARABIC-INDIC DIGIT SEVEN
fn digit_class_is_ascii_only(#[case] name: &str, #[case] expected: bool) {
    assert_eq!(Pattern::new("[[:digit:]]", false).matches(name), expected);
}

Reported by Anthropic's OSS Scanner (ANT-2026-ZURL69PX).

Activity

  1. added
    oss-scanner
    gnu-compat
    on Nov 9, 2026
  2. added a commit that references this issue on Nov 13, 2026
    bebe451
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggnu-compatgood first issueoss-scanner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions