Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zipfile local header extra data is inaccessible #113994

Open
AnyOldName3 opened this issue Jan 12, 2024 · 1 comment · May be fixed by #121413
Open

zipfile local header extra data is inaccessible #113994

AnyOldName3 opened this issue Jan 12, 2024 · 1 comment · May be fixed by #121413
Labels
type-feature A feature request or enhancement

Comments

@AnyOldName3
Copy link

AnyOldName3 commented Jan 12, 2024

Feature or enhancement

Proposal:

Background

I'm trying to extract data from an HTTrack cache zip, documented here https://www.httrack.com/html/cache.html. That has per-file data (which I need) in the per-file local header's extra field field. Currently, the central directory's file header's extra field field is accessible via ZipInfo.extra, but as far as I can tell from the spec, that's not required to be the same thing. For example, 7zip writes NTFS timestamps to the central directory but not the local headers according to https://sourceforge.net/p/sevenzip/bugs/2313/

Proposal

Add some way to access this, and any other interesting local header fields to ZipFile. All the others are things where it only makes sense for a file to have a single value, like the CRC or filename, so it's probably just this one field that matters if only sane zips need to be supported.

Therefore, there could be a method such as ZipFile.getlocalheaderextra(name), functioning roughly like getinfo or read, and returning a bytes object.

Implementing this could be mostly a copy-and-paste job - ZipFile.open already finds the field and seeks past it here

zef_file.seek(fheader[_FH_EXTRA_FIELD_LENGTH], whence=1)

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@AnyOldName3 AnyOldName3 added the type-feature A feature request or enhancement label Jan 12, 2024
Akasurde added a commit to Akasurde/cpython that referenced this issue Jul 5, 2024
Add new attribute local_header to zipinfo to access
information about the local file header as bytes.

Fixes: python#113994

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde Akasurde linked a pull request Jul 5, 2024 that will close this issue
@hpenedones
Copy link

We bumped into this bug as well -- it was hard to track!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants