[PATCH] 5106550: PNG writer merge standard metadata fails for TextEntry sans #IMPLIED attributes

Martin von Gagern Martin.vGagern at gmx.net
Thu Oct 30 11:20:34 PDT 2008


Hi!

I'm trying to follow http://openjdk.java.net/contribute/ in order to get
a patch for http://bugs.sun.com/view_bug.do?bug_id=5106550 into the JDK
7 tree. I hope this is the correct mailing list for it. Sun should have
my signed contributor agreement already, I think.

The bug lies in the fact that for TextEntry nodes in standard metadata
format, PNGMetadata requires additional attributes besides the ones
marked #REQUIRED in the DTD. Namely missing encoding, language or
compression will result in an IIOInvalidTreeException:
> Exception in thread "main" javax.imageio.metadata.IIOInvalidTreeException: Required attribute encoding not present!
> 	at com.sun.imageio.plugins.png.PNGMetadata.fatal(PNGMetadata.java:1085)
> 	at com.sun.imageio.plugins.png.PNGMetadata.getAttribute(PNGMetadata.java:1208)
> 	at com.sun.imageio.plugins.png.PNGMetadata.getAttribute(PNGMetadata.java:1217)
> 	at com.sun.imageio.plugins.png.PNGMetadata.mergeStandardTree(PNGMetadata.java:1921)
> 	at com.sun.imageio.plugins.png.PNGMetadata.mergeTree(PNGMetadata.java:1232)
> 	at MergeStdCommentTest.main(MergeStdCommentTest.java:37)

The patch fixes this by
1. not reading the "encoding" attribute at all,
   as it isn't even used in the following code
2. having the "language" attribute default to "",
   as http://www.w3.org/TR/PNG/#11iTXt states that
   "if the language tag is empty, the language is unspecified"
3. having the "compression" attribute default to "none",
   as this is the default given in the DTD
4. ignore any node with missing or empty "keyword",
   as the PNG standard requires a keyword of length at least 1
   according to http://www.w3.org/TR/PNG/#11tEXt

I changed invocations from the previously used
    private String getAttribute(Node node, String name)
which implied a required argument to the more flexible
    private String getStringAttribute(Node node,
                                      String name,
                                      String defaultValue,
                                      boolean required)

I committed the fix, its test and a later addition in three separate
comitts, and as both "hg export -o filename.patch" and "hg import" seem
to have trouble dealing with more than one changeset in a file, I
attached several separate patch files, as well as a bundle containing
all of these changesets.

Although I subscribed to this list in order to be allowed to send my
contribution (!!), I won't read each and every mail over this list. So
please ensure to include the bug number in any reply, and if you want to
make sure address a copy to me personally as well.

Greetings,
 Martin von Gagern

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bug5106550-fix.patch
Url: http://mail.openjdk.java.net/pipermail/jdk7-dev/attachments/20081030/45150ffe/attachment.ksh 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bug5106550-test.patch
Url: http://mail.openjdk.java.net/pipermail/jdk7-dev/attachments/20081030/45150ffe/attachment-0001.ksh 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bug5106550-nokeyword.patch
Url: http://mail.openjdk.java.net/pipermail/jdk7-dev/attachments/20081030/45150ffe/attachment-0002.ksh 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug5106550.hg
Type: application/octet-stream
Size: 2023 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/jdk7-dev/attachments/20081030/45150ffe/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://mail.openjdk.java.net/pipermail/jdk7-dev/attachments/20081030/45150ffe/attachment.bin 


More information about the jdk7-dev mailing list