If a user loads data into my app selecting an incorrect text encoding and then saves this data to an XML file my app can crash. Here is code to illustrate a crash:
Dim s As String = “aáæ”
Dim s2 As String = ConvertEncoding(s, Encodings.MacRoman)
Dim doc as new XmlDocument
'Dim root as XmlNode = doc.CreateElement(s) // Works
Dim root as XmlNode = doc.CreateElement(s2) // Causes crash
Dim data as String = doc.ToString
On macOS 10.15.7 I get a “AppName quit unexpectedly.” error when ‘doc.ToString’ is called. I see other XmlDocument.ToString issues in Feedback that haven’t been addressed so wondering if there’s a good way to validate the strings that are placed in the XML document to avoid this crash.