Skip to content

Commit

Permalink
fix: raise error on CDATA before or after root
Browse files Browse the repository at this point in the history
  • Loading branch information
lddubeau committed Jul 6, 2018
1 parent bc1e1d4 commit 604241f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ class SAXParser {

case S_OPEN_WAKA_BANG:
if ((this.openWakaBang + c) === CDATA) {
if (!this.sawRoot && !this.reportedTextBeforeRoot) {
this.fail("Text data outside of root node.");
this.reportedTextBeforeRoot = true;
}

if (this.closedRoot && !this.reportedTextAfterRoot) {
this.fail("Text data outside of root node.");
this.reportedTextAfterRoot = true;
}
this.emitNode("onopencdata");
this.state = S_CDATA;
this.openWakaBang = "";
Expand Down

0 comments on commit 604241f

Please sign in to comment.