Skip to content

Commit 1931021

Browse files
committed
Reject an empty quoted abbreviation in the C zoneinfo parser
1 parent bf26921 commit 1931021

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

Lib/test/test_zoneinfo/test_zoneinfo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,9 @@ def test_invalid_tzstr(self):
11491149
"AB C3",
11501150
" A B 3",
11511151
"AAA4BB B,J60/2,J300/2", # Embedded whitespace in DST
1152+
# Empty quoted abbreviation
1153+
"<>5",
1154+
"AAA4<>,M3.2.0/2,M11.1.0/3",
11521155
"PST8PDT,M3.2.0/2", # Only one transition rule
11531156
# Invalid offset hours
11541157
"AAA168",
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
Fix the pure-Python :mod:`zoneinfo` parser accepting an unquoted POSIX TZ
2-
abbreviation that contains characters other than ASCII letters (for example an
3-
embedded space), which the C implementation already rejects. Patch by
4-
tonghuaroot.
1+
Make the C and pure-Python :mod:`zoneinfo` parsers validate POSIX TZ
2+
abbreviations consistently, rejecting unquoted abbreviations with non-letter
3+
characters and empty quoted abbreviations (``<>``). Patch by tonghuaroot.

Modules/_zoneinfo.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,9 @@ parse_abbr(const char **p, PyObject **abbr)
17621762
ptr++;
17631763
}
17641764
str_end = ptr;
1765+
if (str_end == str_start) {
1766+
return -1;
1767+
}
17651768
ptr++;
17661769
}
17671770
else {

0 commit comments

Comments
 (0)