go-plist
go-plist copied to clipboard
Cannot handle empty <integer />
I'm trying to parse the __PRELINK_INFO.__info section on an iOS kernelcache and the embedded plist gives the above error.
Here is a snippet.
<key>UIDeviceFamily</key>
<array>
<integer IDREF="2"/>
</array>
I know this isn't valid plist/xml, but Apple seems to think it is?
Is there anything I/we can do?
Thanks!!
Here is the line: https://github.com/DHowett/go-plist/blob/master/xml_parser.go#L89
So, this is a really curious case. Apple has a number of different XML property list parsers, and cases like this really show off their differences.
I think the kernel one is closer to an actual XML parser. The CoreFoundation one, however, is not. That is most evident here:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<integer IDREF="2" />
</plist>
Error Domain=NSCocoaErrorDomain Code=3840 "Encountered empty <integer> on line
4" UserInfo={NSDebugDescription=Encountered empty <integer> on line 4,
kCFPropertyListOldStyleParsingError=Error Domain=NSCocoaErrorDomain Code=3840
"Malformed data byte group at line 1; invalid hex"
UserInfo={NSDebugDescription=Malformed data byte group at line 1; invalid hex}}
Unfortunately, they haven't really specified the format quite well enough for us to make a determination about what is correct.
Is the prelink property list using a different DOCTYPE declaration than a standard XML property list?
The plist embedded in the binary starts with a <dict> tag with no header. I fixed it in my fork here, but it is a total hack and probably not a good solution: https://github.com/blacktop/go-plist/commit/a935e2ea209256bca0c6ac1e23834600bb29a79a#diff-b46f388ecac749399ab6e09b6c0f1121L89