hey-red / Mime

.NET wrapper for libmagic
MIT License
84 stars 22 forks source link

Excel file type is detected as "bin" #26

Closed VadimPanov closed 6 years ago

VadimPanov commented 6 years ago

Steps to reproduce

Actual result Is detected as 'bin'

Expected result detected as 'xlsx'

I attached the file to this issue

Note: If you open the file in excel and save it, the issue is gone (and size increased from 7kb to 8kb)

New Microsoft Excel Worksheet (2).xlsx

hey-red commented 6 years ago

File maybe too small to detect correct filetype. libmagic just check file headers(signatures) and if no match, returns default type(application/octet-stream with .bin extension)

RezaRahmati commented 6 years ago

Hey @hey-red Thanks for answer, It is interesting that when opening file in excel and just saving it, then it works. Also we have other sample files (that we can't share it here because of sensitive data in it) that they have content and are not small, and same thing happens to them, so I doubt it's related to file size

hey-red commented 6 years ago

@RezaRahmati You can try to build your own magic.mgc, because I don't know when I can update .mgc file in that repo(it very old build). magic.mgc is it compiled libmagic database, that uses these files as source https://github.com/file/file/tree/master/magic/Magdir also, maybe you interesting how libmagic detect .xlsx https://github.com/file/file/blob/master/magic/Magdir/msooxml this file has been recently updated and maybe that will help.

hey-red commented 6 years ago

Package has been updated.