You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been experienced an error with Marcel where having a docx file (a real one) gets detected as application/zip instead of application/vnd.openxmlformats-officedocument.wordprocessingml.document, instead using file --mime-type command correctly detects the right mime type.
I've been researching why this happens and it seems the matchers defined here https://github.com/rails/marcel/blob/main/lib/marcel/tables.rb#L2416 expect a right order of those strings in the file.
I've compared two docx files one that is correctly detected by Marcel and the other one not. It seems that identifier aren't in the correct order. E.g. the [Content_Type].xml check is almost at the end of the file.
The following snippet works but I guess the gem reads first bytes for performance reasons so doesn't have to check include in the whole file.
Hi!
I've been experienced an error with Marcel where having a docx file (a real one) gets detected as
application/zip
instead ofapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
, instead usingfile --mime-type
command correctly detects the right mime type.I've been researching why this happens and it seems the matchers defined here https://github.com/rails/marcel/blob/main/lib/marcel/tables.rb#L2416 expect a right order of those strings in the file.
I've compared two docx files one that is correctly detected by Marcel and the other one not. It seems that identifier aren't in the correct order. E.g. the
[Content_Type].xml
check is almost at the end of the file.The following snippet works but I guess the gem reads first bytes for performance reasons so doesn't have to check include in the whole file.
Cheers
The text was updated successfully, but these errors were encountered: