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

.zip incorrectly detected as .xlsx possible regression #400

Closed
eqinox76 opened this issue Jun 12, 2023 · 0 comments · Fixed by #587
Closed

.zip incorrectly detected as .xlsx possible regression #400

eqinox76 opened this issue Jun 12, 2023 · 0 comments · Fixed by #587

Comments

@eqinox76
Copy link

eqinox76 commented Jun 12, 2023

Expected MIME type
application/zip

Returned MIME type
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Version of the library you are using
v1.4.2

Output of go version
go version go1.20.4 linux/amd64

Additional context
Looks very much like #72. If i zip a .xlsx file without compression its still detected as excel file instead of zip. The file utility detects it fine.

$ zip -0 test2.zip Book1.xlsx 
updating: Book1.xlsx (stored 0%)
$ file test2.zip
test2.zip: Zip archive data, at least v1.0 to extract, compression method=store

Example File: https://filetransfer.io/data-package/pX0B7n1q#link (edited link)

When zipping with compression this library detects the type correctly.

gabriel-vasile added a commit that referenced this issue Oct 8, 2024
https://github.com/file/file/blob/7c62d696b06e53fc5be015c41a57513278ac6c54/magic/Magdir/msooxml
The algorithms is not 100% percent reliable. For example, a
zero compression zip containing a docx will still sometimes be detected
as docx instead of zip (it depends on how many files and the order of
files in the zip)

Second thing in this PR is removing some test data fixtures.
From now, I'll try as much as possible to write regular unit tests
without relying on test file fixtures. #575 (comment)
related #550 #575
closes #400
gabriel-vasile added a commit that referenced this issue Oct 8, 2024
* Make mso detection work similar to what file/file does

https://github.com/file/file/blob/7c62d696b06e53fc5be015c41a57513278ac6c54/magic/Magdir/msooxml
The algorithms is not 100% percent reliable. For example, a
zero compression zip containing a docx will still sometimes be detected
as docx instead of zip (it depends on how many files and the order of
files in the zip)

Second thing in this PR is removing some test data fixtures.
From now, I'll try as much as possible to write regular unit tests
without relying on test file fixtures. #575 (comment)
related #550 #575
closes #400

* zipContains: remove unnecessary zip sig check

The check is already done in parent function.
gabriel-vasile added a commit that referenced this issue Oct 10, 2024
https://github.com/file/file/blob/7c62d696b06e53fc5be015c41a57513278ac6c54/magic/Magdir/msooxml
The algorithms is not 100% percent reliable. For example, a
zero compression zip containing a docx will still sometimes be detected
as docx instead of zip (it depends on how many files and the order of
files in the zip)

Second thing in this PR is removing some test data fixtures.
From now, I'll try as much as possible to write regular unit tests
without relying on test file fixtures. #575 (comment)
related #550 #575
closes #400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant