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.is_zipfile wrongly recognizes non-zip as zip #60939
Comments
When I use zipfile.is_zipfile on file fastjar (sample uploaded at [1]) from libgcj, I get True, while I should get False (reproducible with fastjar from libgcj 4.7.2 on Fedora 18). Thanks a lot. |
You can upload a sample file on bug tracker. Actually jar files are just zip files (with some limitation and special files). zipfile.is_zipfile should return True on a jar file. |
Oh, sorry, I will upload it on the bugtracker next time. I know that jar files are zip files, but this is not a jar (although it has "jar" in file). This is a binary. |
I'm imagining that it creates jar files, and thus has the signature as a constant. The is_zipfile check is much more complicated than just looking for that string, though, so what is going on must be even more perverse than that. It would be interesting to know if other zip tools have an issue with it, although be careful when comparing, since is_zipfile only does the initial check, whereas running another unzip tool against it may produce an error, but only later in the process (after the zip tool has decided it is a zip file and tries to process it). |
$ zipinfo fastjar
Archive: fastjar
Zip file size: 47664 bytes, number of entries: 31883 [fastjar]: I.e. zipinfo detects fastjar as a zip file, but fails to read a contents ( |
So, it looks like this is not a bug in Python, just a weirdness of fastjar. Or, if you prefer, a bug in fastjar (they could assemble the signature instead of coding it as a single constant). |
It's rather a bug in the ZIP format design. |
Well, yes, but that ship has already sunk :) |
Tried is_zipfile on /usr/bin/zip and it returns True, too, so it seems that this is a more general problem for zip-handling binaries... Anyway, thank you both, I agree that there is not much that can be done here. |
zipinfo detects /usr/bin/zip as a zip archive too. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: