Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-152246: Reject a POSIX TZ Mm.w.d rule with a non-period separator …
…in pure-Python zoneinfo
  • Loading branch information
tonghuaroot committed Jun 26, 2026
commit c89a5338f3ebf5c8bbf5cd867804496fa4962c75
5 changes: 5 additions & 0 deletions Lib/test/test_zoneinfo/test_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,11 @@ def test_invalid_tzstr(self):
# Invalid weekday
"AAA4BBB,M1.1.7/2,M2.1.1/2",
"AAA4BBB,M1.1.1/2,M2.1.7/2",
# Invalid Mm.w.d separator (must be a literal '.')
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
"AAA4BBB,M3.2X0,M11.1.0",
"AAA4BBB,M3.2.0,M11.1X0",
"AAA4BBB,M3.2-0,M11.1.0/3",
"AAA4BBB,M3.2.0/2,M11.1:0",
# Invalid numeric offset
"AAA4BBB,-1/2,20/2",
"AAA4BBB,1/2,-1/2",
Expand Down
2 changes: 1 addition & 1 deletion Lib/zoneinfo/_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def _parse_dst_start_end(dststr):
type = date[:1]
if type == "M":
n_is_julian = False
m = re.fullmatch(r"M(\d{1,2})\.(\d).(\d)", date, re.ASCII)
m = re.fullmatch(r"M(\d{1,2})\.(\d)\.(\d)", date, re.ASCII)
if m is None:
raise ValueError(f"Invalid dst start/end date: {dststr}")
date_offset = tuple(map(int, m.groups()))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Fixed a parity bug in the pure-Python :mod:`zoneinfo` implementation, which
accepted a POSIX TZ ``Mm.w.d`` transition rule whose third separator was not a
period (for example ``M3.2X0``). Only the first period was escaped in the
regular expression, so the third one matched any character. Such a string is
invalid per POSIX and is already rejected by the C accelerator. Patch by
tonghuaroot.
Loading