Page 1 of 1

input element with file type does not recognize MIME types in accept attribute

Posted: 2022-08-09, 17:08
by vannilla
I'm not too sure if this is the right place; it's not about a specific website so the web compatibility board also looked wrong.

I searched the release notes in case there was something there (e.g. a setting to toggle) but I could not find anything.

I have this input element:

Code: Select all

<input type="file" name="uploaded_file" accept="image/png">
According to the documentation the file picker should open with a filter showing only the files recognized as being "image/png", but the filter does not apply at all.
Using the extension .png instead of the MIME type works as intended.

This is independent of the type or number of accepted types. Using image/jpeg,image/png does not work while .png,.jpg does.

While I'm normally a Linux user I actually discovered this on a Windows 10 system, in case it matters.

Re: input element with file type does not recognize MIME types in accept attribute

Posted: 2022-08-09, 17:33
by therube
(Out of my league, but) Maybe something here, Bug 1775315 Show .webp & .opus files with audio/* filter in file upload ?

Re: input element with file type does not recognize MIME types in accept attribute

Posted: 2022-08-09, 18:01
by Moonchild
mime types work just fine in <input type=file> - that's been a supported feature for a very long time.
In fact, your very quoted example code does just fine.
It does, however, somewhat depend on whether your file type associations are set up properly - if you for some reason have removed application associations then this may cause problems if the mime type is no longer known. In that case the restriction is probably ignored since the browser won't know what to do with the presented mime type.

Re: input element with file type does not recognize MIME types in accept attribute

Posted: 2022-08-09, 20:15
by vannilla
If it's about file associations it might be the case then.
I have limited access to that machine, so I can't change too much personally.
I was led astray by the fact that other browsers always work, but that's probably because they ignore the OS and do things in their own way.

Re: input element with file type does not recognize MIME types in accept attribute

Posted: 2022-08-09, 20:56
by Moonchild
Well, internally-handled MIME types should always work unless they were explicitly removed from the browser's configuration. Without more information though I can't really tell what's going on, but there is no bug in the browser at least as far as I can tell.
Maybe check what's going on in preferences -> applications?
Did the browser profile get mangled or "privacy hardened" or what not?

Re: input element with file type does not recognize MIME types in accept attribute

Posted: 2022-08-10, 08:35
by vannilla
I discovered an important detail and it turns out this Pale Moon is actually the portable version!
That would explain the issue with the file associations since the portable version is not supposed to have them (or anyway have a limited set?)
I've been a Linux user for a long while now and Windows systems are getting more and more unfamiliar as time passes (I even have trouble navigating the Windows 10 settings window!), so I end up in situations like this one.
What I thought was an error somewhere ended up simply with Pale Moon being special.
Sorry for the pointless report, but I really couldn't figure it out until now!