[OpenJDK 2D-Dev] 6541476: PNG imageio plugin incorrectly handles iTXt chunk
Martin von Gagern
Martin.vGagern at gmx.net
Mon Nov 10 10:58:36 UTC 2008
Bug 6541476; State: 8-Fix Available, bug; Priority: 4-Low
PNGMetadata is inconsitent in what data types get stored in its various
iTXt_* lists. Method mergeNativeTree used different data types than the
rest of the code for the following two attributes:
1. iTXt_compressionFlag uses Integer, but Boolean in mergeNativeTree
2. iTXt_compressionMethod uses Integer, but String in mergeNativeTree
The attached patch addresses this by:
1. Changing all Lists to compile time type checked generics.
Now the code compiles with -Xlint:unchecked
2. Cast the boolean compressionFlag to an integer before adding
3. Request the compressionMethod as an integer attribute
4. Change the comment about the compressionMethod datatype in the DTD
5. Provide a simple test case
The compressionMethod of the iTXtEntry element is worth a closer look.
While compressionMethod attributes of other elements in the native PNG
metadata format use enum types in the DTD, this one has been defined as
String in the spec and represented as integers on export so far. I
believe it would be better to turn it into an enum as well, probably in
a way which would retain backward and forward compatibility.
However, I would consider this a separate issue, and discuss it in a
separate thread. Therefore I'd deem this patch here ready to be applied
as a self comtained fix for a single issue, even though I would like for
another fix to change the DTD again before OpenJDK7 gets released.
The Evaluation of CR 6541476 also mentions some issues reading UTF8 data
for iTXt chunks. This I'd also consider a separate issue, and would
address it in a separate fix, along with a separate test case to
reproduce the issue in the first place.
The attached patch is from my mercurial patch queue. Once you consider
it ready for inclusion, I will commit it locally and export a mercurial
Martin von Gagern
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the 2d-dev