From 23ba49ac43386b16e7d0de44dfd37c6dfdafaf41 Mon Sep 17 00:00:00 2001 From: Prahalad Kumar Narayanan Date: Thu, 22 Mar 2018 11:41:15 +0530 Subject: [PATCH] 6686236: GIF native IIOMetadata assumes characterCellWidth/Height as 2bytes Reviewed-by: prr, jdv --- .../plugins/gif/GIFImageMetadataFormat.java | 6 +- .../plugins/gif/GIFWritableImageMetadata.java | 9 +- .../metadata/doc-files/gif_metadata.html | 6 +- .../plugins/gif/GIFCharCellDimensionTest.java | 160 ++++++++++++++++++ 4 files changed, 172 insertions(+), 9 deletions(-) create mode 100644 test/jdk/javax/imageio/plugins/gif/GIFCharCellDimensionTest.java diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadataFormat.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadataFormat.java index fa982d7e698..fa55d72bbda 100644 --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadataFormat.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadataFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,10 +119,10 @@ public class GIFImageMetadataFormat extends IIOMetadataFormatImpl { "1", "65535", true, true); addAttribute("PlainTextExtension", "characterCellWidth", DATATYPE_INTEGER, true, null, - "1", "65535", true, true); + "1", "255", true, true); addAttribute("PlainTextExtension", "characterCellHeight", DATATYPE_INTEGER, true, null, - "1", "65535", true, true); + "1", "255", true, true); addAttribute("PlainTextExtension", "textForegroundColor", DATATYPE_INTEGER, true, null, "0", "255", true, true); diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFWritableImageMetadata.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFWritableImageMetadata.java index 41621151d1e..dc780602a90 100644 --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFWritableImageMetadata.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFWritableImageMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -203,15 +203,18 @@ class GIFWritableImageMetadata extends GIFImageMetadata { -1, true, true, 1, 65535); + // As per the specification (89a), character cell width + // and character cell height occupy one byte each + // in the Plain Text Extension block. characterCellWidth = getIntAttribute(node, "characterCellWidth", -1, true, - true, 1, 65535); + true, 1, 255); characterCellHeight = getIntAttribute(node, "characterCellHeight", -1, true, - true, 1, 65535); + true, 1, 255); textForegroundColor = getIntAttribute(node, "textForegroundColor", diff --git a/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html b/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html index 2c6ed584d2e..16a04d13ee6 100644 --- a/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html +++ b/src/java.desktop/share/classes/javax/imageio/metadata/doc-files/gif_metadata.html @@ -5,7 +5,7 @@ GIF Metadata Format Specification