From 611e9e3a6fa5df3abf022b614b1280a22e64ae7c Mon Sep 17 00:00:00 2001 From: David A Roberts Date: Fri, 25 May 2018 13:28:41 +1000 Subject: [PATCH] JSDOMParser: handle CDATA sections --- JSDOMParser.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/JSDOMParser.js b/JSDOMParser.js index 889c6db..a9219d7 100644 --- a/JSDOMParser.js +++ b/JSDOMParser.js @@ -1075,6 +1075,18 @@ return textNode; } + if (this.match("![CDATA[")) { + var endChar = this.html.indexOf("]]>", this.currentChar); + if (endChar === -1) { + this.error("unclosed CDATA section"); + return null; + } + var text = new Text(); + text.textContent = this.html.substring(this.currentChar, endChar); + this.currentChar = endChar + ("]]>").length; + return text; + } + c = this.peekNext(); // Read Comment node. Normally, Comment nodes know their inner