test(format/date-time): add trailing newline as invalid#959
Open
vtushar06 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the JSON Schema Test Suite’s date-time format coverage by adding a negative test case for RFC 3339 date-time strings that include a single trailing line feed (\n), ensuring validators reject input with any trailing characters after the time offset.
Changes:
- Added an invalid
date-timeformat test for a trailing newline:"1985-04-12T23:20:50Z\n"(expectedvalid: false). - Applied the same test addition consistently across draft3/draft4/draft6/draft7/draft2019-09/draft2020-12 optional suites and the v1 suite.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/v1/format/date-time.json | Adds an invalid trailing-newline date-time test case to the v1 suite. |
| tests/draft7/optional/format/date-time.json | Adds the same invalid trailing-newline date-time test case for draft7 optional format tests. |
| tests/draft6/optional/format/date-time.json | Adds the same invalid trailing-newline date-time test case for draft6 optional format tests. |
| tests/draft4/optional/format/date-time.json | Adds the same invalid trailing-newline date-time test case for draft4 optional format tests. |
| tests/draft3/optional/format/date-time.json | Adds the same invalid trailing-newline date-time test case for draft3 optional format tests. |
| tests/draft2020-12/optional/format/date-time.json | Adds the same invalid trailing-newline date-time test case for draft2020-12 optional format tests. |
| tests/draft2019-09/optional/format/date-time.json | Adds the same invalid trailing-newline date-time test case for draft2019-09 optional format tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jviotti
approved these changes
Jul 1, 2026
jviotti
left a comment
Member
There was a problem hiding this comment.
I guess this is a good example of how weird regexes can get across languages, confusing users of pattern, etc
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.
Following the methodology I used for ipv4 and uuid, I read RFC 3339 section 5.6 and found the suite has no date-time test for a trailing newline.
RFC 3339 section 5.6 defines
date-time = full-date "T" full-time, and every production is a fixed sequence of digits and literals ending at the time-offset - the grammar emits no line feed, so nothing may follow the offset. A single trailing\nis therefore invalid. The suite tests a trailing space (Z) and trailing content (Z extra), both of which the reference validator rejects; it does not test the newline, which the reference validator accepts.Changes
1985-04-12T23:20:50Z\n- a valid date-time followed by a single line feed - invalid.Ecosystem Impact
date-timecheck delegates to rfc3339-validator, which buildsRFC3339_REGEX + "$"and callsre.match; Python's$matches immediately before a single trailing\n, so the line feed is never seen.ZandZ extraget rejected, butZ\nslips through.$without themflag matches only at the very end of the string, so the trailing\nis not consumed.is_rfc3339_datetime: PASSES (rejects it) - it requires the whole string to parse.RFC References
Reproduction and the date-time cross-implementation matrix are in my evidence repo: https://github.com/vtushar06/JSON-Schema-format-test-Evidence/blob/main/date-time.md
Related: #965