Repository navigation
Conversation
The zone part of the pattern had no right boundary, so "CET" matched the military zone "C" (+03:00), "HST" matched "H" (+08:00), "IST" matched "I" (+09:00) and so on. The date was parsed with a wrong offset instead of raising ArgumentError, as it already does for "JST". Require the zone not to be followed by a letter or a digit. Comments and other separators after the zone are still accepted. Also accept "UTC", which used to match only as "UT" followed by "C".
nobu
reviewed
Nov 18, 2026
Comment on lines
+527
to
+528
| UTC|UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z]) | ||
| (?![a-z\d])/ix =~ date |
Member
There was a problem hiding this comment.
Suggested change
| UTC|UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z]) | |
| (?![a-z\d])/ix =~ date | |
| UTC|UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z])\b/ix =~ date |
Suggested by nobu.
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.
Time.rfc2822has no right boundary after the zone, so a longer zone name matches its first letter as a military zone:So these strings are parsed with a wrong offset (off by up to 18 hours) instead of raising
ArgumentErrorlikeJSTdoes, and a caller that rescues and falls back toTime.parsenever gets the chance.The fix adds
\bafter the zone. Comments and other separators are still accepted (-0330 (Newfoundland Time),GMT(comment), a trailing,).UTCis added to the list because it used to match only asUTfollowed byC; the result is the same as before.Tests: new
test_rfc2822_zone_endfails before and passes after;rake testpasses (54 tests). I also ran 30k generated dates (numeric, named and military zones, with and without comments/trailing text) through the old and new code: the only changes are inputs where the zone is directly followed by a letter or digit, which now raise.