Skip to content
Myr

Reject out-of-range '@' Unix timestamp instead of panicking

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Use UNIX_EPOCH.checked_add(...) so an out-of-range value returns None and propagates through the existing ? like every other parse failure in TimeFilter::from_str, rather than panicking via SystemTime's Add. See #2081.

authored by Nikolaus Schuetz · committed by Nikolaus Schuetz · parent fb0426f · Browse files · 2 files+2 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+2 added−1 removed

  • other:+2 added−1 removed

2 files+2 added−1 removed

modified:src/filter/time.rs+1 added-1 removed
40 unmodified lines
41 .into(),42 )43 } else {44 let timestamp_secs: u64 = s.strip_prefix('@')?.parse().ok()?;45 Some(UNIX_EPOCH + Duration::from_secs(timestamp_secs))45 UNIX_EPOCH.checked_add(Duration::from_secs(timestamp_secs))46 }47 }4849 pub fn before(s: &str) -> Option<TimeFilter> {
161 unmodified lines
modified:CHANGELOG.md+1 added
11 unmodified lines
12- Handle invalid working directories gracefully when using `--full-path`, see #1900 (@Xavrir).13- Fire the "search pattern contains a path separator" diagnostic for any pattern containing `/`, not just patterns that happen to name an existing directory. Preserves the legacy Windows behaviour that also flags native `\` separators when the pattern resolves to a real directory. See #1873.14- Also fire the "search pattern contains a path separator" diagnostic for `--and` patterns, not only the primary positional pattern. `--and` patterns are matched against the file name just like the primary pattern, so a path separator in them silently returned zero results. See #1873.15- Fix bug where passing "-" as a directory argument didn't actually search that directory, see #849 (@Sean-Kenneth-Doherty).16- Fix panic when `--changed-before`/`--changed-within` is given an out-of-range `@` Unix timestamp; the value is now rejected gracefully, see #2081 (@nikolauspschuetz).1718# 10.4.21920## Bugfixes
848 unmodified lines