Closed solind closed 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 (�).
Also your branch contains other changes which I would like to consider separately.
Commit e802f1c4d857e934adcfe22110d2eba2678b0206 fixes the outputting of illegal characters by stripping them from the string before writing the XML.
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.