xmldom icon indicating copy to clipboard operation
xmldom copied to clipboard

Fix "]]>" serialization in text nodes

Open Holzhaus opened this issue 7 years ago • 2 comments

This fixes issue #164, which is a regression caused by commit 47fa9b8. Before, text nodes were serialized correctly (thanks to commit 22fff92).

Section 2.4 of the XML 1.0 (5th Ed) recommendation states:

The right angle bracket (>) may be represented using the string
">", and MUST, for compatibility, be escaped using either ">"
or a character reference when it appears in the string "]]>" in
content, when that string is not marking the end of a CDATA section.

See https://www.w3.org/TR/2008/REC-xml-20081126/#syntax for details.

Thus, this commit escapes the right angle bracket in text nodes if it appears as part of "]]>". If not, the right angle bracket is not escaped.

The unittest that was broken since commit 47fa9b8 has been fixed, too.

Holzhaus avatar May 27 '17 11:05 Holzhaus

@Holzhaus you might consider incorporating https://github.com/jindw/xmldom/pull/132 for fullness of the PR.

smoke avatar Nov 08 '17 10:11 smoke

Also hit this issue, given this seems to be stuck here, we'll need to fork and port. Thanks for the PR!

santiagoaguiar avatar Jun 21 '19 16:06 santiagoaguiar