Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildcard MIME subtype

I'd like to use image/* MIME type in data URI e.g. data:image/*;base64,R0lGODlhE... in <img/> element.

  • Is it standard-compliant MIME type at all?
  • Can it cause problems in some browsers and if so, in which?
like image 669
Maxim Kachurovskiy Avatar asked Aug 13 '15 16:08

Maxim Kachurovskiy


1 Answers

image/* isn't an official MIME type (though browsers may be smart enough to render it).

According to RFC 2046 (Section 4.2) there are two ways you can handle generic / unknown images:

Unrecognized subtypes of "image" should at a miniumum be treated as "application/octet-stream". Implementations may optionally elect to pass subtypes of "image" that they do not specifically recognize to a secure and robust general-purpose image viewing application, if such an application is available.

NOTE: Using of a generic-purpose image viewing application this way inherits the security problems of the most dangerous type supported by the application.

That being said, you could pass the most generic (and official) MIME type which is application/octet-stream or you could use image/image. Any browser should be able to figure out the image type, but I don't know for sure. From what I've seen, browsers have no issue for jpg, gif, png - but I can't say what the case is for the many other file types.

like image 86
Parker Avatar answered Nov 18 '22 08:11

Parker