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
Prev Previous commit
Next Next commit
Reject an empty quoted abbreviation in the C zoneinfo parser
  • Loading branch information
tonghuaroot committed Jun 26, 2026
commit 1931021bd2f0e91bfbe4d4a4e26f7ee61c894003
3 changes: 3 additions & 0 deletions Lib/test/test_zoneinfo/test_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,9 @@ def test_invalid_tzstr(self):
"AB C3",
" A B 3",
"AAA4BB B,J60/2,J300/2", # Embedded whitespace in DST
# Empty quoted abbreviation
"<>5",
"AAA4<>,M3.2.0/2,M11.1.0/3",
"PST8PDT,M3.2.0/2", # Only one transition rule
# Invalid offset hours
"AAA168",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Fix the pure-Python :mod:`zoneinfo` parser accepting an unquoted POSIX TZ
abbreviation that contains characters other than ASCII letters (for example an
embedded space), which the C implementation already rejects. Patch by
tonghuaroot.
Make the C and pure-Python :mod:`zoneinfo` parsers validate POSIX TZ
abbreviations consistently, rejecting unquoted abbreviations with non-letter
characters and empty quoted abbreviations (``<>``). Patch by tonghuaroot.
Comment thread
StanFromIreland marked this conversation as resolved.
Outdated
3 changes: 3 additions & 0 deletions Modules/_zoneinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,9 @@ parse_abbr(const char **p, PyObject **abbr)
ptr++;
}
str_end = ptr;
if (str_end == str_start) {
return -1;
}
ptr++;
}
else {
Expand Down
Loading