Fix ISO8601Utils#parse time zone validation - #3131
Open
Marcono1234 wants to merge 2 commits into
Open
Marcono1234 wants to merge 2 commits into
Marcono1234 wants to merge 2 commits into
Conversation
Marcono1234
commented
Sep 30, 2026
| * @see <a href="http://www.w3.org/TR/NOTE-datetime">this specification</a> | ||
| */ | ||
| // Date parsing code from Jackson databind ISO8601Utils.java | ||
| // Date parsing code from Jackson databind ISO8601Utils.java, with modifications |
Contributor
Author
There was a problem hiding this comment.
Just added this as clarification; the code already contained Gson-specific modifications before, see Git history
Comment on lines
+245
to
+247
| if (date.length() > offset) { | ||
| throw new IllegalArgumentException("Trailing data after time zone 'Z'"); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Alternative would be to remove this check here again and let it fail in parseFully instead.
(It seems in all other cases trailing invalid data is already rejected.)
Marcono1234
marked this pull request as ready for review
September 30, 2026 11:34
4 tasks done
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.
Purpose
Not sure why the author closed their PR. The changes here are recreated and not taken as is from the original PR.
Description
As mentioned in #3111 there is a bug in the current
ISO8601Utils#parseimplementation when a short time zone such as+00is extended to+0000, causing the parsing end offset to be incorrect.This had previously no visible effect for users because Gson did not validate the parsing end offset.
It also fixes that trailing data after the time zone indicator
Zwas not rejected.