From 3ce0a8594f6579c578c8002986297cc73c92a325 Mon Sep 17 00:00:00 2001 From: Harald Kuhr Date: Sun, 22 Mar 2015 14:25:29 +0100 Subject: [PATCH] TMI-121: Clean up. --- .../plugins/jpeg/JPEGSegmentImageInputStream.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/imageio/imageio-jpeg/src/main/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGSegmentImageInputStream.java b/imageio/imageio-jpeg/src/main/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGSegmentImageInputStream.java index 639fdab9..bfb10eb8 100644 --- a/imageio/imageio-jpeg/src/main/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGSegmentImageInputStream.java +++ b/imageio/imageio-jpeg/src/main/java/com/twelvemonkeys/imageio/plugins/jpeg/JPEGSegmentImageInputStream.java @@ -117,13 +117,12 @@ final class JPEGSegmentImageInputStream extends ImageInputStreamImpl { marker = 0xff00 | stream.readUnsignedByte(); } - // TODO: Should we just skip all app marker segments? - // We are now handling all important segments ourselves - // TODO: Need to re-insert the APP14, and instead make sure we limit it to 16 bytes, - // OR use two delegates, one for reading image data, and one for reading metadata... - boolean isApp14Adobe = false; - if (isAppSegmentMarker(marker) && !(marker == JPEG.APP1 && isAppSegmentWithId("Exif", stream) - || (isApp14Adobe = (marker == JPEG.APP14 && isAppSegmentWithId("Adobe", stream))))) { + // We are now handling all important segments ourselves, except APP1/Exif and APP14/Adobe, as these + boolean appSegmentMarker = isAppSegmentMarker(marker); + boolean isApp14Adobe = marker == JPEG.APP14 && isAppSegmentWithId("Adobe", stream); + boolean isApp1Exif = marker == JPEG.APP1 && isAppSegmentWithId("Exif", stream); + + if (appSegmentMarker && !(isApp1Exif || isApp14Adobe)) { int length = stream.readUnsignedShort(); // Length including length field itself stream.seek(realPosition + 2 + length); // Skip marker (2) + length }