Repository navigation
Validate the hour, minute, second and offset ranges of the time format - #227
Merged
Merged
Conversation
The time regex used \d{1,2} for the hour, minute and second and \d\d:\d\d
for the offset, so values such as 29:99:99 or 12:00:00+24:00 were
accepted. Use 0-23 for the hour, 0-59 for the minute, 0-60 for the
second (RFC 3339 leap second) and 00-23:00-59 for the offset. The
optional parts and the one-digit forms the regex already accepted are
unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
The
timeformat regex (draft 7 and later) checks the hour, minute and second with\d{1,2}and the offset with\d\d:\d\d, so it accepts values that cannot be RFC 3339 times:The regex now uses 0-23 for the hour, 0-59 for the minute, 0-60 for the seconds (RFC 3339 leap second) and
(?:[01]\d|2[0-3]):[0-5]\dfor the offset. The shape is unchanged: the one-digit forms and the optional seconds/offset that the regex already accepted stay accepted, as this is the same approach as thedate-timefix in #225.Tests: a new
test_timeintests/test_format.pywith 14 rows (five valid values including the leap second, two malformed values, seven out-of-range values). The seven out-of-range rows fail onmasterand all pass with this change; the rest of the suite passes (631 passed, 4 skipped, withtests/benchmarksleft out).CHANGELOG.txthas an entry under UNRELEASED.This change was made with Claude Code.
🤖 Generated with Claude Code