react-dropzone / attr-accept

JavaScript implementation of the "accept" attribute for HTML5 input element
MIT License
110 stars 24 forks source link

accept: MIME type should be case insensitive #50

Closed antoineol closed 4 years ago

antoineol commented 4 years ago

Do you want to request a feature or report a bug?

What is the current behavior?

The MIME type check with accept config is case-sensitive, but it should be case-insensitive according to SO / specs. Source: https://stackoverflow.com/a/12869287/4717408. Here is a scenario where it impacts the behavior. For an Excel file with extension .xlsm, we have the MIME types:

This leads to a behavior a bit hard to understand when I develop on Windows (I have copy/pasted the official MIME type which is the first variant, so I'm not aware of the case issue) and I test later on Mac. If I'm not familiar with detailed MIME type specs like being case-sensitive or not, or different platforms providing different cases, it will take some time before I find the source cause.

If the current behavior is a bug, please provide the steps to reproduce.

Sandbox: https://codesandbox.io/s/vigilant-curran-jqxwi

  1. provide accept: "application/vnd.ms-excel.sheet.macroEnabled.12" MIME type filter
  2. Try on Windows: it works (you can upload .xlsm Excel files)
  3. Try on Mac: it does NOT work. Reason: the MIME type on Mac is application/vnd.ms-excel.sheet.macroenabled.12 (lower-case e)

What is the expected behavior?

The MIME type should be case-insensitive, so providing any case in the accept config should work.

Please mention other relevant information such as the browser version, Operating System and react-dropzone version.

Chrome, latest version on Windows and Mac

The current workaround is to provide both cases in the list of accepted MIME types: https://codesandbox.io/s/agitated-night-52c6b


Issue initially created here

Btw, thanks for this great lib!


[Edit] Here is the PR: https://github.com/react-dropzone/attr-accept/pull/51

rolandjitsu commented 4 years ago

Closed with #51.