fix: reject unknown IANA time zones in Instant::toString() - #73
Open
ethanhawkes-gif wants to merge 1 commit into
Open
fix: reject unknown IANA time zones in Instant::toString()#73ethanhawkes-gif wants to merge 1 commit into
ethanhawkes-gif wants to merge 1 commit into
Conversation
validateTimeZoneString() only checks syntax, so a well-formed but unrecognized IANA identifier (e.g. "Bogus/Zone") reaches the offset lookup and is silently rendered as UTC, while toZonedDateTimeISO() correctly throws a RangeError for the same input. The two entry points disagreed. Per TC39 (ToTemporalTimeZoneIdentifier / GetAvailableNamedTimeZoneIdentifier) an unknown time zone identifier is a RangeError. Make the two toString() swallow sites throw instead: - ianaOffsetSeconds(): a bare unknown IANA name (was: return 0 -> UTC) - resolveTimeZoneOffsetSeconds(): an unknown bracket zone that previously fell through to the inline offset Adds Porcelain regression tests for both unknown-zone paths plus positive coverage for valid bare and bracketed IANA zones. Fixes MidnightDesign#60 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: ethanhawkes-gif <259455325+ethanhawkes-gif@users.noreply.github.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.
Fixes #60.
Problem
validateTimeZoneString()only checks syntax, so a well-formed but unrecognized IANA identifier passes it and reaches the offset lookup, where it is silently rendered as UTC — whiletoZonedDateTimeISO()correctly throws aRangeErrorfor the same input. The two entry points disagreed.Per TC39 (
ToTemporalTimeZoneIdentifier/GetAvailableNamedTimeZoneIdentifier), an unknown time zone identifier is aRangeError.Fix
Two
toString()-path swallow sites now throw instead, matchingtoZonedDateTimeISO():ianaOffsetSeconds()— a bare unknown IANA name previously fell back to offset0(→ UTC).resolveTimeZoneOffsetSeconds()— an unknown bracket zone previously fell through to the inline offset.Both helpers are private with a single caller each, only in the
toString()path.Tests
Adds Porcelain regression tests for both unknown-zone paths plus positive coverage for valid bare and bracketed IANA zones. Local verification:
🤖 Generated with Claude Code