You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
find: -newerXt with a non-ASCII-digit year aborts instead of erroring #759
The -newerXt time options (-newermt, -newerat, -newerct, -newerBt) parse the year field of their date argument with .parse::<i32>().unwrap() (src/find/matchers/mod.rs:384). The year is captured by a regex whose \d class matches Unicode decimal digits (the regex crate defaults to Unicode mode, so \d == \p{Nd}), but str::parse::<i32>() accepts only ASCII digits. So a year written with four non-ASCII decimal digits (Arabic-Indic, Devanagari, fullwidth, …) passes the regex and then panics in parse, aborting the process with exit 101.
$ find . -newermt 'jan 01, ٠٠٠٠'thread 'main' panicked at src/find/matchers/mod.rs:384:56:called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo$?101
Any four non-ASCII decimal digits in the year field trigger it — the digit system is irrelevant:
let regex_pattern =
r"^(?P<month_day>\w{3} \d{2})?(?:, (?P<year>\d{4}))?(?: (?P<time>\d{2}:\d{2}:\d{2}))?$";let re = Regex::new(regex_pattern);ifletSome(captures) = re.ok()?.captures(date_str){
...
let year = captures
.get(2).map_or(now.year(), |m| m.as_str().parse().unwrap());// <-- mod.rs:384: panics
...
let datetime = NaiveDateTime::parse_from_str(&date_time_str,"%b %d, %Y %H:%M:%S").ok()?;
...}
\d{4} matches four Unicode decimal digits, but m.as_str().parse::<i32>() (the type is inferred from the now.year(): i32 branch) rejects non-ASCII digits with ParseIntError { kind: InvalidDigit }, which the .unwrap() turns into a panic.
Activity