[3.13] gh-152246: Fix pure-Python zoneinfo accepting invalid seperators in POSIX TZ rules (GH-152247) (#152267)

(cherry picked from commit f47acc7f09)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
This commit is contained in:
Miss Islington (bot) 2026-06-26 14:04:35 +02:00 committed by GitHub
parent d740050c99
commit 82a54898ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View file

@ -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
"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",

View file

@ -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()))

View file

@ -0,0 +1,2 @@
Fix the pure-Python :mod:`zoneinfo` parser accepting an invalid POSIX TZ
transition rule with a non-period separator. Patch by tonghuaroot.