diff --git a/dom.js b/dom.js index b13b371..6864f8c 100644 --- a/dom.js +++ b/dom.js @@ -1053,7 +1053,7 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){ case ATTRIBUTE_NODE: return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"'); case TEXT_NODE: - return buf.push(node.data.replace(/[<&]/g,_xmlEncoder)); + return buf.push(node.data.replace(/[<&]/g,_xmlEncoder).replace(/\]\]>/g,']]'+_xmlEncoder('>'))); case CDATA_SECTION_NODE: return buf.push( ''); case COMMENT_NODE: diff --git a/test/dom/serializer.js b/test/dom/serializer.js index d9df5b9..407d44e 100644 --- a/test/dom/serializer.js +++ b/test/dom/serializer.js @@ -5,7 +5,7 @@ wows.describe('XML Serializer').addBatch({ 'text node containing "]]>"': function() { var doc = new DOMParser().parseFromString('', 'text/xml'); doc.documentElement.appendChild(doc.createTextNode('hello ]]> there')); - console.assert(doc.documentElement.firstChild.toString() == 'hello ]]> there',doc.documentElement.firstChild.toString()); + console.assert(doc.documentElement.firstChild.toString() == 'hello ]]> there',doc.documentElement.firstChild.toString()); }, '', 'text/html');