Skip to content

Reject malformed ISO 8601 timezone with a doubled colon#31

Merged
oalders merged 1 commit into
masterfrom
fix-7
Jun 25, 2026
Merged

Reject malformed ISO 8601 timezone with a doubled colon#31
oalders merged 1 commit into
masterfrom
fix-7

Conversation

@oalders

@oalders oalders commented Jun 25, 2026

Copy link
Copy Markdown
Member

Closes #7

Problem

parse_date accepted a malformed ISO 8601 timezone such as 1996-02-29 12:00:00 -01::00 and returned the bad string -01::00 verbatim as the timezone field.

Cause

The timezone sub-pattern used a capturing group (:?[0-9][0-9]) where a non-capturing group (?:[0-9][0-9]) was intended — the : and ? were transposed. The stray inner :? let a second colon be consumed, so a doubled colon slipped through.

Fix

Use a non-capturing group (?:[0-9][0-9]) so the colon separator is matched only by the outer :?. Well-formed offsets (-01:00, -0100, -01, Z) are unaffected.

Testing

  • Added a regression test asserting parse_date("...-01::00") returns an empty list; verified it fails on the pre-fix code and passes with the fix.
  • Added positive tests confirming -01:00, -0100, and -01 still parse with the timezone returned intact.
  • Full suite passes (172 tests).

The ISO 8601 timezone sub-pattern used a capturing group `(:?\d\d)`
where a non-capturing group `(?:\d\d)` was intended. The transposed
`:?`/`?:` let an extra colon slip through, so parse_date() accepted
malformed offsets like `-01::00` and returned them verbatim as the
timezone.

Use a non-capturing group so the colon separator is matched only by
the outer `:?`. Well-formed offsets (-01:00, -0100, -01) are
unaffected.

Closes #7

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.70%. Comparing base (e45e4ca) to head (b1c9746).

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #31   +/-   ##
=======================================
  Coverage   89.70%   89.70%           
=======================================
  Files           1        1           
  Lines          68       68           
  Branches       29       29           
=======================================
  Hits           61       61           
  Misses          1        1           
  Partials        6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oalders oalders marked this pull request as ready for review June 25, 2026 15:04
@oalders oalders merged commit 80c9c4c into master Jun 25, 2026
51 checks passed
@oalders oalders deleted the fix-7 branch June 25, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP::Date::parse_date accepts iso-date with malformed TZ: "1996-02-29 12:00:00 -01::00" [rt.cpan.org #101378]

1 participant