3breadt / dd-plist

A java library providing support for ASCII, XML and binary property lists.
Other
258 stars 94 forks source link

ASCIIPropertyListParser fails to read file that contains only comment #67

Closed jpstotz closed 3 years ago

jpstotz commented 3 years ago

I encountered an empty plist file in old ASCII format:

/* Localized versions of Info.plist keys */

If you use dd-plist to parse such a file you end up with the following exception:

java.lang.ArrayIndexOutOfBoundsException: 45
    at com.dd.plist.ASCIIPropertyListParser.accept(ASCIIPropertyListParser.java:267)
    at com.dd.plist.ASCIIPropertyListParser.skipWhitespacesAndComments(ASCIIPropertyListParser.java:353)
    at com.dd.plist.ASCIIPropertyListParser.parse(ASCIIPropertyListParser.java:430)
    at com.dd.plist.ASCIIPropertyListParser.parse(ASCIIPropertyListParser.java:238)
    at com.dd.plist.ASCIIPropertyListParser.parse(ASCIIPropertyListParser.java:220)
    at com.dd.plist.ASCIIPropertyListParser.parse(ASCIIPropertyListParser.java:172)
    at com.dd.plist.ASCIIPropertyListParser.parse(ASCIIPropertyListParser.java:127)

If I interpret the description of such ASCII plist files correctly the file should be valid https://en.wikipedia.org/wiki/Property_list#NeXTSTEP

At least I would have expected a ParseException instead of an ArrayIndexOutOfBoundsException

BTW: I noticed that the Unit test https://github.com/3breadt/dd-plist/blob/master/src/test/java/com/dd/plist/test/ParseTest.java#L149-L167 contains a lot of tests that are disabled as they miss the @Test annotation. Are those tests disabled intentionally or is this a bug?