3breadt / dd-plist

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

Eliminating null characters from XML representations #56

Closed solind closed 4 years ago

solind commented 4 years ago

I have updated the NSString class.toXML() method to properly handle the occasional case where a null from a null-terminated string somehow ends up in the String data. A null character must never appear in an XML document, or any validating parser will reject it.

3breadt commented 4 years ago

How do you get a \0 into the string? Does it happen when parsing binary property lists or do your strings come from another source?

I am not in favor of your solution. Simply assuming that the string was originally null terminated may not always be correct.

Additionally other characters that are considered illegal in XML 1.0 would also need to be addressed.

I would suggest simply removing them or replacing them with the Unicode replacement character (�).

3breadt commented 4 years ago

Also your branch contains other changes which I would like to consider separately.

3breadt commented 4 years ago

Commit e802f1c4d857e934adcfe22110d2eba2678b0206 fixes the outputting of illegal characters by stripping them from the string before writing the XML.