moov-io / signedxml

pure go library for processing signed XML documents
MIT License
52 stars 44 forks source link

Fix issue where adjacent comments were skipped during canonicalization #51

Closed laurenkt closed 5 months ago

laurenkt commented 6 months ago

Addresses issue #50

If comments were adjacent in a document with no whitespace between them, then for each pair of comments the second comment would be skipped due to the underlying slice being modified as it was being ranged over.

For example, the following document:

<a><!-- comment1 --><!-- comment2 --><!-- comment 3 --></a>

Would be incorrectly canonicalized to:

<a><!-- comment2 --></a>

This patch fixes that issue and adds a new test case to cover it.