Repository navigation
find: report an unparsable -newerXt year instead of panicking - #762
Merged
Merged
Conversation
The -newerXt options parsed the year with `.parse().unwrap()`, but the
capturing regex's `\d{4}` matches Unicode decimal digits while
`str::parse` accepts only ASCII. A year of four non-ASCII digits
(e.g. `jan 01, ٠٠٠٠`) passed the regex and then panicked, aborting with
exit 101. Fold the failed parse into the existing None path so it
reports the GNU-style "I cannot figure out how to interpret ..." error
with exit 1, as uutils already does for other malformed dates.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #762 +/- ##
=======================================
Coverage 91.88% 91.88%
=======================================
Files 35 35
Lines 7159 7160 +1
Branches 377 377
=======================================
+ Hits 6578 6579 +1
Misses 437 437
Partials 144 144 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit 97d8100 has test result changes: bfs testsuite: |
Contributor
|
Thanks! |
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #759.
-newerXt(-newermt/-newerat/-newerct/-newerBt) parsed the year field with.parse().unwrap(). The capturing regex's\d{4}matches Unicode decimal digits (theregexcrate defaults to Unicode mode), butstr::parseaccepts only ASCII, so a year of four non-ASCII digits (e.g.find . -newermt 'jan 01, ٠٠٠٠') passed the regex and then panicked, aborting with exit 101.This folds a failed year parse into the function's existing
Nonepath, so the argument is reported asfind: I cannot figure out how to interpret ‘…’ as a date or time(exit 1) — matching GNU findutils and what uutils already does for other malformed dates. Added a regression assertion toparse_date_str_to_timestamps_test.