Skip to content

Commit 82a5489

Browse files
miss-islingtontonghuarootStanFromIreland
authored
[3.13] gh-152246: Fix pure-Python zoneinfo accepting invalid seperators in POSIX TZ rules (GH-152247) (#152267)
(cherry picked from commit f47acc7) Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com> Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent d740050 commit 82a5489

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/test/test_zoneinfo/test_zoneinfo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,11 @@ def test_invalid_tzstr(self):
11841184
# Invalid weekday
11851185
"AAA4BBB,M1.1.7/2,M2.1.1/2",
11861186
"AAA4BBB,M1.1.1/2,M2.1.7/2",
1187+
# Invalid Mm.w.d separator
1188+
"AAA4BBB,M3.2X0,M11.1.0",
1189+
"AAA4BBB,M3.2.0,M11.1X0",
1190+
"AAA4BBB,M3.2-0,M11.1.0/3",
1191+
"AAA4BBB,M3.2.0/2,M11.1:0",
11871192
# Invalid numeric offset
11881193
"AAA4BBB,-1/2,20/2",
11891194
"AAA4BBB,1/2,-1/2",

Lib/zoneinfo/_zoneinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def _parse_dst_start_end(dststr):
707707
type = date[:1]
708708
if type == "M":
709709
n_is_julian = False
710-
m = re.fullmatch(r"M(\d{1,2})\.(\d).(\d)", date, re.ASCII)
710+
m = re.fullmatch(r"M(\d{1,2})\.(\d)\.(\d)", date, re.ASCII)
711711
if m is None:
712712
raise ValueError(f"Invalid dst start/end date: {dststr}")
713713
date_offset = tuple(map(int, m.groups()))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the pure-Python :mod:`zoneinfo` parser accepting an invalid POSIX TZ
2+
transition rule with a non-period separator. Patch by tonghuaroot.

0 commit comments

Comments
 (0)