RFR: 8277572: Image class documentation incorrect for images encoded in data URIs

Michael Strauß mstrauss at openjdk.java.net
Mon Nov 22 17:57:35 UTC 2021


The javadoc of `javafx.scene.image.Image` incorrectly states:

    94    * If a URL uses the "data" scheme, the data must be base64-encoded
    95    * and the MIME type must either be empty or a subtype of the
    96    * {@code image} type.

However, omitting the MIME type of a data URI is specified to imply "text/plain" (RFC 2397, section 2). Since the `com.sun.javafx.util.DataURI` class is implemented according to this specification, trying to load an image without MIME type correctly fails with an `ImageStorageException`: "Unexpected MIME type: text".

The solution is to fix the documentation:

      94    * If a URL uses the "data" scheme, the data must be base64-encoded
    + 95    * and the MIME type must be a subtype of the {@code image} type.
    - 95    * and the MIME type must either be empty or a subtype of the
    - 96    * {@code image} type.

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

Commit messages:
 - Fixed incorrect documentation of image data URIs

Changes: https://git.openjdk.java.net/jfx/pull/676/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jfx&pr=676&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8277572
  Stats: 32 lines in 2 files changed: 30 ins; 1 del; 1 mod
  Patch: https://git.openjdk.java.net/jfx/pull/676.diff
  Fetch: git fetch https://git.openjdk.java.net/jfx pull/676/head:pull/676

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


More information about the openjfx-dev mailing list