jscher2000 / Content-Type-Fixer-extension

Firefox extension to override dumb Content-Type headers with correct values
Mozilla Public License 2.0
23 stars 2 forks source link

Discussion: Prioritizing content type over file extension #2

Closed irvinm closed 4 years ago

irvinm commented 4 years ago

I'm starting to see a different type of situation where a URL is requesting a resource say example.tif and it adds an argument to transmit the file as a WEBP file to reduce the size. When trying to save the file, the browser sees the content type as "image/webp" and prompts to save the file as "example.tif".

When tying to open the file, most applications will say that they file is "unrecognized". Obviously renaming the file to example.webp will open properly when using an appropriate viewer.

I personally don't mind WEBP files (to reduce space), but in these type of situations I can not tell if exmaple.tif is a TIF file, WEBP file, or possibly a corrupted file until I try to view the file and then then try different extensions.

I see a handful of possible solutions:

  1. Try to prevent a site from transmitting WEBP files. Could try removing formatting arguments in a URL (tedious for each site if even possible) or even disabling WEBP support for all of Firefox via configuration changes (which could break some sites).
  2. Trust that the content type is correct and override the file extension via an addon in some circumstances. (In this case, save it as example.webp vs. example.tif because the content type is reported as "image/webp")

Example:

https://images.bloomingdalesassets.com/is/image/BLM/products/2/optimized/10631592_fpx.tif?op_sharpen=1&wid=1200&fit=fit,1&$filtersm$&fmt=webp

Any thoughts\suggestions? Do you think I am missing anything?

irvinm commented 4 years ago

Sorry, I think this might be related to another addon. When I save this file manually via "Save Image As..." it saves the file as "10631592_fpx.tif.webp" which is what I might expect and obviously opens fine. I will verify and close this out. (I am using the addon "Save In ..." to facilitate saving files to different folders.)

jscher2000 commented 4 years ago

Hmm, yes, if a file.tif comes with text/plain or binary/blahblah, then you know it's not a useful content type, but there may be cases where the incorrect type actually is the best type for the file. Tough problem.

irvinm commented 4 years ago

Yes, definitely a tough problem. For me it was primarily the introduction of WEBP (which I am actually "for") which has caused these problems. I'm sure this will iron itself over time.