通配符 MIME 子类型
Wildcard MIME subtype
我想在数据 URI 中使用 image/*
MIME 类型,例如data:image/*;base64,R0lGODlhE...
在 <img/>
元素中。
- 它是否完全符合标准的 MIME 类型?
- 它会在某些浏览器中引起问题吗?如果是,在哪些浏览器中?
image/*
不是官方的 MIME 类型(尽管浏览器可能足够智能以呈现它)。
根据RFC 2046(第 4.2 节),您可以通过两种方式处理通用/未知图像:
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.
也就是说,您可以传递最通用(和官方)的 MIME 类型,即 application/octet-stream
或 您可以使用 image/image
。任何浏览器都应该能够识别图像类型,但我不确定。据我所知,浏览器对 jpg
、gif
、png
没有问题 - 但我不能说其他许多文件类型的情况如何。
我想在数据 URI 中使用 image/*
MIME 类型,例如data:image/*;base64,R0lGODlhE...
在 <img/>
元素中。
- 它是否完全符合标准的 MIME 类型?
- 它会在某些浏览器中引起问题吗?如果是,在哪些浏览器中?
image/*
不是官方的 MIME 类型(尽管浏览器可能足够智能以呈现它)。
根据RFC 2046(第 4.2 节),您可以通过两种方式处理通用/未知图像:
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.
也就是说,您可以传递最通用(和官方)的 MIME 类型,即 application/octet-stream
或 您可以使用 image/image
。任何浏览器都应该能够识别图像类型,但我不确定。据我所知,浏览器对 jpg
、gif
、png
没有问题 - 但我不能说其他许多文件类型的情况如何。