RFR: 8277572: ImageStorage should correctly handle MIME types for images encoded in data URIs [v2]

Michael Strauß mstrauss at openjdk.java.net
Tue Nov 23 16:03:21 UTC 2021


On Tue, 23 Nov 2021 15:33:49 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

> This seems like an odd behavior to me, but if this is common practice among browsers, then it seems OK for us to do the same. In this case, it should be documented in the class docs of `Image`.

I've tested this with Chrome and Edge, and these browsers go even further. If the image format has a detectable signature, the image will be displayed regardless of the specified MIME type (even if it is not an `image` type). The MIME type only matters for image formats without signature, like SVG. In this case, the image will not be displayed if the MIME type is incorrect.

I think that a compromise works best for JavaFX. We probably don't want to allow plainly incorrect MIME types, but in cases where we know what the developer should have specified, a warning seems like a good nudge in the right direction.

-------------

PR: https://git.openjdk.java.net/jfx/pull/676


More information about the openjfx-dev mailing list