Closed Bug 1948264 Opened 1 month ago Closed 1 month ago

IMG element load PNG with wrong mime-type, but not SVG

Categories

(Firefox :: Untriaged, defect)

Firefox 135
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: david.balazic, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0

Steps to reproduce:

In a HTML document (served over HTTPS):

<IMG src="/images/foo.svg" alt="foo bar">

<IMG src="/images/bar.png" alt="bar baz">

If both image URLs have "Content-Type: application/octet-stream" in the response, only the PNG will be shown on the page, while the SVG not.

Fixing the server to send "Content-Type: image/svg+xml" will make SVG also appear.

This is consistent between Firefox v135.0 and MS Edge v133

Why this difference in handling SVG and PNG inline images?

Formally (to qualify this for a bug report): SVG images are not loaded if content type is wrong, while PNGs are

https://mimesniff.spec.whatwg.org/#mime-type-sniffing-algorithm

  1. If the supplied MIME type is an image MIME type supported by the user agent, let matched-type be the result of executing the image type pattern matching algorithm with the resource header as the byte sequence to be matched.

The algorithm has no rules that would lead to the SVG mime-type being sniffed.

Status: UNCONFIRMED → RESOLVED
Closed: 1 month ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.