markov2 / perl5-MIME-Types

Definition of MIME types
http://perl.overmeer.net/CPAN
4 stars 1 forks source link

Too many x- prefixes #12

Closed labster closed 3 years ago

labster commented 3 years ago

I'm fairly sure that .webp should be image/webp, not image/x-webp. Of course, it's not on the IANA list, because why would they document widely deployed ten year old standards? But it is on this list: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

By sending the wrong type in Dancer2 for .webp, Firefox decides to treat it as a file download rather than simply viewing the image. Pretty sure it's the same change for .webm as well. It looks like the apache list that got uploaded last month has the correct changes, but types.db does not.

markov2 commented 3 years ago

MIME-Types are defined by RFC2046, https://datatracker.ietf.org/doc/html/rfc2046 Section 4.2, restricts the image types to the ones registered by IANA. Section 2.3.1 offers an escape adding "x-" until registration is complete. So, there is no valid reason to use the type with x-. Until registered at IANA, someone else can claim image/webp

RFC2046 dates from, but is a new version of RFC1521 which obsoleted RFC1341 which became a standard in June 1992. Far before Google existed. More than a zillion other organizations did take the time to fill-in a 10 field registration form.

Concluding: that people do accept image/webp is because they bend for Google. This is really arrogant behavior. Question is: by stupidity or on purpose?

labster commented 3 years ago

Until registered at IANA, someone else can claim image/webp

Try it, see how far you get 😁

But seriously I use Firefox all the time as a main browser and yet here we are where Google gets to run the web. I guess the application for this type got submitted last month, long after it was a de facto standard.

I've already worked around this in my own code... but I'm starting to wonder if I should open another Firefox bug so it can sit around a decade or two.

markov2 commented 3 years ago

You never know whether the RFC will make it, but it tells us that they have submitted it to IANA. IANA can be slow (volunteers): you should start registering in an early stage of your development. At this moment, image/webp in not accepted, hence should still be used as image/x-webp under strict rules.

You can make a work-around like this:

my $mt = MIME::Types->new;
$mt->addType(MIME::Type->new(extension => [ 'webp' ], type => 'image/webp');

That should overrule the translation.

Let's not wait for IANA: I'll add both types to my "work around issues" exception list.

markov2 commented 3 years ago

I have few changes on the module, so let's not wait. Uploaded 2.21 to CPAN.