Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
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 @@ -1222,6 +1222,11 @@ def test_invalid_tzstr(self):
"AAA4BBB,J60/2:00:100,J300/2",
"AAA4BBB,J60/2,J300/2:00:0",
"AAA4BBB,J60/2,J300/2:00:100",
# gh-152248: unquoted abbreviation must be ASCII letters only
"A A4BBB,J60/2,J300/2", # space in std abbreviation
"AAA4B B,J60/2,J300/2", # space in dst abbreviation
"ÄAA4BBB,J60/2,J300/2", # non-ASCII letter in std
"AAA4ÄBB,J60/2,J300/2", # non-ASCII letter in dst
]

for invalid_tzstr in invalid_tzstrs:
Expand Down
4 changes: 2 additions & 2 deletions Lib/zoneinfo/_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,11 +640,11 @@ def _parse_tz_str(tz_str):

parser_re = re.compile(
r"""
(?P<std>[^<0-9:.+-]+|<[a-zA-Z0-9+-]+>)
(?P<std>[a-zA-Z]+|<[a-zA-Z0-9+-]+>)
(?:
(?P<stdoff>[+-]?\d{1,3}(?::\d{2}(?::\d{2})?)?)
(?:
(?P<dst>[^0-9:.+-]+|<[a-zA-Z0-9+-]+>)
(?P<dst>[a-zA-Z]+|<[a-zA-Z0-9+-]+>)
(?P<dstoff>[+-]?\d{1,3}(?::\d{2}(?::\d{2})?)?)?
)? # dst
)? # stdoff
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix the pure-Python :func:`zoneinfo._parse_tz_str` to reject unquoted
POSIX TZ string abbreviations containing non-ASCII characters or
whitespace, matching the C implementation's behavior.
Loading