Skip to content

gh-160420: Reject drive letters in ZoneInfo key components on Windows - #160421

Draft
gpshead wants to merge 1 commit into
python:mainfrom
gpshead:scanfix-tzpath-izmaolcq
Draft

gpshead wants to merge 1 commit into
python:mainfrom
gpshead:scanfix-tzpath-izmaolcq

Conversation

@gpshead

@gpshead gpshead commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

_validate_tzfile_path() now also checks each /-separated component of a ZoneInfo key with os.path.splitroot() and raises ValueError if it has a drive or root. Before, a key such as America/C:\Windows\win.ini passed validation on Windows, and load_tzdata() joined C:\Windows\win.ini to the tzdata package directory, which replaced it. No POSIX key changes behaviour, and all keys in the system time zone database still validate under ntpath.

I could not run this on Windows. The new test runs the validator with os.path swapped for ntpath, so it exercises the Windows rules on every platform, but the end-to-end behaviour with tzdata installed on Windows is checked by code inspection only.

The 3.11 backport needs a manual port: os.path.splitroot() is new in 3.12, so the automated cherry-pick would produce code that fails there. On 3.11 the check can be written as os.path.splitdrive(component)[0] or os.path.isabs(component).

Fixes #160420

ANT-2026-IZMAOLCQ

…indows

A key such as "America/C:\file" passed validation, and the tzdata
loader then joined "C:\file" to the package directory, which replaced
it.

ANT-2026-IZMAOLCQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zoneinfo.ZoneInfo accepts keys with a drive letter in a later component on Windows

1 participant