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

compatibility is broken with certain types of office documents #35

Closed
fursich opened this issue Mar 29, 2021 · 3 comments
Closed

compatibility is broken with certain types of office documents #35

fursich opened this issue Mar 29, 2021 · 3 comments

Comments

@fursich
Copy link
Contributor

fursich commented Mar 29, 2021

Hi - first of all A HUGE THANKS for your recent hard work!
I can't thank you enough for your dedication that saved entire rails community (and of course, myself included) from license problems.

By the way, we have just upgraded our Rails app with marcel 1.0.0, and found that some tests started failing due to mis-detection of xlsx formats.

summary

  • certain xlsx files are mis-detected as 'application/zip':
> Marcel::MimeType.for File.open('spec/fixtures/document/excel/sample.xlsx')
=> "application/zip"
  • after some investigation, it turned out that the files are all generated by google sheet (by exporting original google sheets as xlsx)

  • the files seem to have valid xlsx format, because it can be viewed correctly by ms excel.

reproduction case

To reproduce above case, let me submit a PR separately with mis-detected files attached as fixture.

quick analysis and a few thoughts..

It looks like the parts that consists of office open document doesn't have a fixed order.
So in some cases, [Contents_Type].xml doesn't come immediately after the first 30 bytes.

Currently marcel is very specific about where to expect[Contents_Type].xml, whereas mimemagic used to look up wider ranges to find the part.

Would that make sense to relax the area for magic match, so that it can detect much varied xlsx's?

@wilkosz
Copy link

wilkosz commented Apr 1, 2021

I think there may be a few further inconsistencies with various other file formats.

> Marcel::MimeType.for File.open('...')
=> "application/zip"

Affected file types ott ots odp otp ppt pptm odt ods odg

Example Files at https://drive.google.com/drive/folders/1124-kGCs5sJ1Ng5pXmIzwQLk1CgnWjb4?usp=sharing

@rocket-turtle
Copy link

@wilkosz does this change fixes the result for this files?
#38

@wilkosz
Copy link

wilkosz commented Apr 1, 2021

@wilkosz does this change fixes the result for this files?
#38

Thanks, @rocket-turtle, this solves all our inconsistencies

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

No branches or pull requests

4 participants