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

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2181
Joined: 2018-05-05, 13:29

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

Unread post by vannilla » 2022-08-09, 17:08

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.


User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35404
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

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

Unread post by Moonchild » 2022-08-09, 18:01

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.
Attachments
Image2.png
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2181
Joined: 2018-05-05, 13:29

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

Unread post by vannilla » 2022-08-09, 20:15

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.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35404
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

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

Unread post by Moonchild » 2022-08-09, 20:56

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?
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2181
Joined: 2018-05-05, 13:29

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

Unread post by vannilla » 2022-08-10, 08:35

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!

Locked