Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

zipfile.Path regression #123270

Closed
jaraco/zipp
#124
Assignees
jaraco
Labels
3.10only security fixes3.11only security fixes3.12only security fixes3.13bugs and security fixes3.14bugs and security fixes3.8 (EOL)end of life3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errortype-securityA security issue
@obfusk

Description

@obfusk

Bug report

Bug description:

#122906 introduced a regression with directories that look like Windows drive letters (on Linux):

>>>importio,zipfile>>>zf=zipfile.ZipFile(io.BytesIO(),"w")>>>zf.writestr("d:/foo","bar")>>>zf.extractall("a")>>>open("a/d:/foo").read()'bar'>>>p=zipfile.Path(zf)>>>x=p/"d"/"foo">>>y=p/"d:"/"foo">>>list(p.iterdir())# before: [Path(None, 'd:/')][Path(None,'d/')]>>>p.root.namelist()# before: ['d:/foo', 'd:/']['d/foo','d/']>>>x.exists()# before: FalseTrue>>>y.exists()# before: TrueFalse>>>zf.extractall("b")# before: worked like aboveKeyError:"There is no item named 'd/foo' in the archive">>>x.read_text()# before: FileNotFoundErrorKeyError:"There is no item named 'd/foo' in the archive">>>y.read_text()# before: workedFileNotFoundError: ...

This is the result of_sanitize() unconditionally treating a directory that looks like a drive letter as such and removing the colon, regardless of operating system:

bare=re.sub('^([A-Z]):',r'\1',name,flags=re.IGNORECASE)

Whereas_extract_member() usesos.path.splitdrive() (which is a no-op on Linux):

arcname=os.path.splitdrive(arcname)[1]

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

3.10only security fixes3.11only security fixes3.12only security fixes3.13bugs and security fixes3.14bugs and security fixes3.8 (EOL)end of life3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errortype-securityA security issue

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp