Repository navigation
Validate the month, day and hour ranges of the date-time format - #225
Merged
horejsek merged 1 commit intoOct 20, 2026
Merged
Conversation
The date-time regex used [01]\d for the month, [0-3]\d for the day and [0-2]\d for the hour, so values such as 2020-19-39T29:00:00Z were accepted, while the leap second 23:59:60Z allowed by RFC 3339 was rejected. Use 01-12, 01-31, 00-23 (also for the offset hours) and 00-60 for the seconds. The day is not checked against the length of the month, and the +hhmm offset form stays accepted. 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
date-timeformat regex checks the date and time fields with the loose classes[01]\d(month),[0-3]\d(day) and[0-2]\d(hour), and the seconds with[0-5]\d. So it accepts values that cannot be RFC 3339 date-times and rejects one that can:The regex now uses
0[1-9]|1[0-2]for the month,0[1-9]|[12]\d|3[01]for the day,[01]\d|2[0-3]for the hour (also in the offset), and[0-5]\d|60for the seconds. The shape of the regex is unchanged: the day is still not checked against the length of the month, and the+hhmmoffset form that the existing tests expect stays accepted.Tests: thirteen rows added to
test_datetimeintests/test_format.py(two leap-second values that must be accepted, eleven out-of-range values that must be rejected). Eleven fail onmasterand all pass with this change; the rest of the suite passes (614 passed, 4 skipped, withtests/benchmarksleft out).CHANGELOG.txthas an entry under UNRELEASED.This change was made with Claude Code.
🤖 Generated with Claude Code