File MIME type is overwritten by OS-level settings
Categories
(Firefox :: File Handling, defect, P3)
Tracking
()
People
(Reporter: chriskirknielsen, Unassigned)
References
(Blocks 1 open bug)
Details
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0
Steps to reproduce:
- Create a form with a file input
- Select a CSV file from your computer
- Programmatically read the file's MIME in JavaScript (
File.type)
OS: Windows 10
Firefox 100: Error
Chrome 107: OK
Actual results:
While working on a project for a client, they came across a bug we could not reproduce. It turned out the MIME type of a file provided in an upload input was being overwritten by OS settings.
The file type in question is a CSV file. On my test Windows machine, I did not have Excel or any Microsoft Office apps installed. The client however, did.
While my .csv files were returned as text/csv consistently, theirs returned application/vnd.ms-excel.
These files were tested and confirmed to be real CSV files and not just renamed Excel files.
Expected results:
Common filetypes like CSV should be reliably set to their "natural" MIME type, and not allow the OS to overwrite it if software has been set to the default handler for that file type.
I can fully understand that some filetypes might be obscure and this allows to get more reliable information, but some MIME types should be safe from this behaviour if they are common enough. Other browsers like Chrome do not trigger this issue and seemingly parse the "natural" MIME type regardless of OS settings.
| Reporter | ||
Updated•3 years ago
|
Comment 1•3 years ago
|
||
I was able to reproduce this issue as well on a Windows 10 machine with Microsoft Excell installed on it in all versions of Firefox.
Any downloaded CSV file when we upload it to a form like the example here: https://web.dev/read-files/ we always get the:
name: text.csv, type: application/vnd.ms-excel - Firefox
name: text.csv, type: text/csv, - Chrome
This issue does not occur on machines where Microsoft Excell is not installed.
Comment 2•3 years ago
|
||
Since this works in Chrome and not in Firefox, I'm thinking its an actual bug on the Firefox side even though it always worked this way, if not we can move it back to Enhancement.
Comment 3•3 years ago
|
||
Turns out Chrome fixed this specific issue for CSV in February of this year.
Updated•3 years ago
|
Comment 5•3 years ago
|
||
Similarly Bug 1802080 reports a case with xlsx associated to WPS Office and thus returning their own specific mime application/wps-office.xlsx
There is likely a relation with bug 254862, because of course we have mime type to file type associations playing a role there.
Comment 6•3 years ago
|
||
See also bug 786657, we should ensure we're not still using potentially bogus downloads information (in handlers.json) for uploads.
Comment 7•1 year ago
|
||
I'm also running into this where a text/csv is being sent as application/vnd.ms-excel and it's preventing me from using some features on a site. I'm getting the expected MIME type on Chrome using this Codepen, but on Firefox, it's reporting the excel MIME type.
Behaviour is reproducable here with a .csv file upload: https://codepen.io/crespire/pen/myJPywP
Description
•