Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8156306 | 8u111 | Ramanand Patil | P4 | Resolved | Fixed | b01 |
JDK-8148035 | 8u102 | Ramanand Patil | P4 | Resolved | Fixed | b01 |
JDK-8162145 | emb-8u111 | Ramanand Patil | P4 | Resolved | Fixed | b01 |
FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
A DESCRIPTION OF THE PROBLEM :
For some JPEG images the method java.net.URLConnection#guessContentTypeFromStream will return the MIME type image/jpg, which is not a valid, registered IANA mime type for JPEG images.
For other images, the correct MIME type (image/jpeg) is returned.
It could be open for debate how invalid image/jpg truly is, but here's the IANA list:
http://www.iana.org/assignments/media-types/media-types.xhtml
Regardless of the validity of the MIME type, I could not find any information on *why* Java will return two different MIME types for JPEGs.
Sadly I cannot provide the image that triggered the relevant detection code (it's from a customer), but after some googling, it seems like the relevant JPEG APP14 header is an application specific header, in this case from Adobe (see http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The function should return image/jpeg for all JPEG images, not just some.
ACTUAL -
The function returned image/jpg for some JPEG images encoded with Adobe software.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Manually replacing image/jpg in the result with image/jpeg.
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
A DESCRIPTION OF THE PROBLEM :
For some JPEG images the method java.net.URLConnection#guessContentTypeFromStream will return the MIME type image/jpg, which is not a valid, registered IANA mime type for JPEG images.
For other images, the correct MIME type (image/jpeg) is returned.
It could be open for debate how invalid image/jpg truly is, but here's the IANA list:
http://www.iana.org/assignments/media-types/media-types.xhtml
Regardless of the validity of the MIME type, I could not find any information on *why* Java will return two different MIME types for JPEGs.
Sadly I cannot provide the image that triggered the relevant detection code (it's from a customer), but after some googling, it seems like the relevant JPEG APP14 header is an application specific header, in this case from Adobe (see http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The function should return image/jpeg for all JPEG images, not just some.
ACTUAL -
The function returned image/jpg for some JPEG images encoded with Adobe software.
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Manually replacing image/jpg in the result with image/jpeg.
- backported by
-
JDK-8148035 URLConnection.guessContentTypeFromStream returns image/jpg for some JPEG images
- Resolved
-
JDK-8156306 URLConnection.guessContentTypeFromStream returns image/jpg for some JPEG images
- Resolved
-
JDK-8162145 URLConnection.guessContentTypeFromStream returns image/jpg for some JPEG images
- Resolved