Repository navigation
Conversation
The date, date-time and time format regexes matched digits with \d, which in a Python str pattern is any Unicode decimal digit, while RFC 3339 allows only 0-9. A date with a Bengali 4 in the day or with a fullwidth year was accepted, although date.fromisoformat() raises ValueError on it. Match the digits with [0-9] instead.
This branch has not been deployed
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.
date,date-timeandtimeformats accept non-ASCII digitsThe format regexes match digits with
\d, which for a Pythonstrpattern is any Unicode decimal digit, not only the0-9that RFC 3339 allows:Format checks run on the data being validated, so a field declared as
dateordate-timecan carry a value that passes the validator and then raises infromisoformat(), or thatint()reads as an ordinary number (int('১৯৬৩') == 1963) while other consumers reject it.\dis now[0-9]inDATE_REGEX(shared bydateanddate-time), in the time part ofdate-timeand intime. No other built-in format uses\d. For ASCII input the old and new regexes accept exactly the same strings (checked over 300k generated strings). The JSON-Schema-Test-Suite "invalid non-ASCII" cases for these three formats now pass in every draft. The cases added totests/test_format.pyfail onmasterand pass here, the rest of the suite passes on Python 3.10, 3.11 and 3.13, and pylint reports nothing new.CHANGELOG.txthas an entry under UNRELEASED.