From a065b1d1e17966fdfd716aa3964062014b1e4aef Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sun, 11 Jun 2017 20:17:13 +0200 Subject: [PATCH 1/2] Add test for !DOCTYPE with internal subset --- test/parse/node.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/parse/node.js b/test/parse/node.js index 7548818..855e889 100644 --- a/test/parse/node.js +++ b/test/parse/node.js @@ -98,7 +98,11 @@ wows.describe('XML Node Parse').addBatch({ var doc = parser.parseFromString('', 'text/html'); console.log(doc+'') - } + }, + 'internal subset':function(){ + var doc = (new DOMParser()).parseFromString('bar"> ]>', 'text/xml'); + console.assert(doc+'' == '', doc+'') + }, }).run(); // Run it //var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1; //var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2; From e8dfa6d0bf9be57544c1f63a01baa7bddd58cbde Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Sun, 11 Jun 2017 20:17:53 +0200 Subject: [PATCH 2/2] sax: Don't choke on internal subset in !DOCTYPE This fixes #210. Please note that this just discards all contents of the interal subset, so support should be improved later on. --- sax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sax.js b/sax.js index f8b494e..2fad780 100644 --- a/sax.js +++ b/sax.js @@ -603,7 +603,7 @@ ElementAttributes.prototype = { function split(source,start){ var match; var buf = []; - var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g; + var reg = /'[^']+'|"[^"]+"|\[[^\]]+]|[^\s<>\/=]+=?|(\/?\s*>|<)/g; reg.lastIndex = start; reg.exec(source);//skip < while(match = reg.exec(source)){