mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
_zoneinfo: reject empty quoted POSIX TZ abbreviations (#9017)
* Reject empty quoted POSIX timezone abbreviations Split the Python 3.14-compatible parser guard from #8954. Cover empty standard and daylight-saving abbreviations and preserve valid quoted names. Assisted-by: OpenAI Codex:model identifier unavailable * Keep zoneinfo regression in module snippet Rename the snippet as requested during review without changing test contents. Assisted-by: OpenAI Codex:model identifier unavailable
This commit is contained in:
1 parent
8986de27cc
commit
59b36dd426
2 files changed
+22
No files matched your search
@@ -552,6 +552,9 @@ mod _zoneinfo {
|
||||
parser.bump();
|
||||
}
|
||||
let end = parser.i;
|
||||
if end == start {
|
||||
return None;
|
||||
}
|
||||
parser.bump();
|
||||
return Some(String::from_utf8_lossy(&parser.bytes[start..end]).into_owned());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import io
|
||||
import struct
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from testutils import assert_raises
|
||||
|
||||
# Minimal TZif v3 data with no transitions and a POSIX rule in the footer.
|
||||
header = (b"TZif3" + b"\0" * 15 + struct.pack(">6l", 0, 0, 0, 0, 0, 0)) * 2
|
||||
|
||||
|
||||
def zone_from_rule(rule):
|
||||
return ZoneInfo.from_file(io.BytesIO(header + b"\n" + rule + b"\n"))
|
||||
|
||||
|
||||
for rule in (b"<>5", b"AAA4<>,M3.2.0/2,M11.1.0/3"):
|
||||
assert_raises(ValueError, zone_from_rule, rule)
|
||||
|
||||
# Quoting still permits nonempty numeric abbreviations.
|
||||
assert zone_from_rule(b"<+05>-5").tzname(None) == "+05"
|
||||
Reference in new issue
Block a user