Open Bug 1801755 Opened 3 years ago Updated 11 months ago

File MIME type is overwritten by OS-level settings

Categories

(Firefox :: File Handling, defect, P3)

Firefox 100
Desktop
All
defect

Tracking

()

Tracking Status
firefox-esr102 --- affected
firefox107 --- affected
firefox108 --- affected
firefox109 --- affected

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:

  1. Create a form with a file input
  2. Select a CSV file from your computer
  3. 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.

Component: General → File Handling
Product: Core → Firefox

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.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → All
Hardware: Unspecified → Desktop

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.

Type: enhancement → defect

Turns out Chrome fixed this specific issue for CSV in February of this year.

Duplicate of this bug: 1802080

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.

Blocks: 254862
Priority: -- → P3

See also bug 786657, we should ensure we're not still using potentially bogus downloads information (in handlers.json) for uploads.

See Also: → 786657

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

See Also: → 1934918
You need to log in before you can comment on or make changes to this bug.