Skip to content

zipfile.ZipFile discards directory entries on read #154398

Description

@smiRaphi

Bug report

Bug description:

when opening a standard java .jar file, zipfile discards all directory entries making it not match the original file when rewriting the .jar, I've looked into the zipfile code and I cannot see any logic for discarding so I feel like I'm going kinda crazy, I've looked into the file with a hex editor and even ran it through a custom zip parser and I can assure that the file is in no way corrupt or non standard.

Here is the file I'm working with, please do note that I'm using an adblocker so the url might be unsafe without one, I've made it non clickable for that reason:
[https://] optifine [dot] net/adloadx?f=preview_OptiFine_26.1.2_HD_U_K1_pre2.jar

Here's an example snippet of the problem:

import zipfile
z = zipfile.ZipFile('preview_OptiFine_26.1.2_HD_U_K1_pre2.jar','r')
try: z.getinfo('assets/')
except KeyError as e: print(e.__class__.__name__,e)
try: z.getinfo('assets')
except KeyError as e: print(e.__class__.__name__,e)
z.close()

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions