Skip to content

Commit

Permalink
Add a check when loading XML and verify it was successfully parsed. T…
Browse files Browse the repository at this point in the history
…his avoid generating a bad export where the data are not actually exported due to invalid XML being generated by Application.ExportXML. Unfortunately, if a table contains any characters that aren't valid for XML document, it won't try to escape them and include them as literals. Even if they were escaped, they might not be accepted anyway. XML specifications forbids having any characters in 0x01-0x31 range so if a table data contains such characters, this can cause the XML export to fail. In this case, tab delimited will have to be used instead. However, the previous version was simply silently exporting as if everything is hunky-dory when it's not. Hence, the error.
  • Loading branch information
bclothier committed Oct 19, 2023
1 parent 734d835 commit 4703b7b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Version Control.accda.src/modules/modSanitize.bas
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,11 @@ Public Function SanitizeXML(strPath As String, blnReturnHash As Boolean) As Stri
Set objXml = New MSXML2.DOMDocument60
End If

objXml.LoadXML strFile
If objXml.LoadXML(strFile) = False Then
Log.Error eelError, _
"Unable to parse the XML for file '" & strPath & "'. This may be due to containing malformed XML. Check the source XML document for validity. In some cases, this may be due to table data containing characters not allowed in XML documents.", ModuleName & ".SanitizeXML"
Exit Function
End If

' Determine if it's a table data with schema
For Each objNode In objXml.SelectNodes("/root/dataroot")
Expand Down

0 comments on commit 4703b7b

Please sign in to comment.