Make XmlDiff compliant with the XML spec - #395
Conversation
XML spec section 2.11 requires end-of-line characters to be normalized to LF, and whitespace inside attributes to be normalized to spaces (no tabs, CR, or LF characters). Our current XmlDiff implementation would find diffs where none should be found, and this will fix that bug.
|
It looks like the 01b27ec bugfix is just an illusion caused by a bad test assertion. If you remove 01b27ec then one test fails, the EnsureMergedCData_IsRetained test in ChorusNotesFileHandlerTests. But what that test is doing is doing the same merge the "old way" and the "new way" and then comparing the merge results by a string comparison. Thing is, without the 01b27ec change (which just sets <?xml version="1.0" ... ?>
<notes version="0">
<annotation ...>
<message ...>And the "new way" results in this: <?xml version="1.0" ... ?>
<notes version="0">
<annotation ...>
<message ...>Those extra newlines between XML elements are not semantically significant, and so the test should have compared them and concluded they were equal. Yet it's using a string comparison, and I'll leave 01b27ec in, because it's been in place for over a decade and a half and there's no point in removing it now. And I won't change the EnsureMergedCData_IsRetained test now. But it's a poor test, checking the wrong thing, and failing on a false positive. |
XML spec section 2.11 requires end-of-line characters to be normalized to LF, and whitespace inside attributes to be normalized to spaces (no tabs, CR, or LF characters). Our current XmlDiff implementation would find diffs where none should be found, and this will fix that bug.
Fixes #361.
This would probably also have fixed the bug that 01b27ec was trying to fix, though I haven't verified that yet.
This change is