Skip to content

Commit

Permalink
fix: CDATA end in attributes must not cause an error
Browse files Browse the repository at this point in the history
  • Loading branch information
lddubeau committed Aug 31, 2018
1 parent 283bcfe commit a7495ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
3 changes: 0 additions & 3 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1384,9 +1384,6 @@ class SaxesParser {
this.fail("disallowed character.");
}
else if (c) {
if (this.attribValue.includes("]]>")) {
this.fail("the string \"]]>\" is disallowed in char data.");
}
this.attribList.push({ name: this.name, value: this.attribValue });
this.name = this.attribValue = "";
this.q = null;
Expand Down
6 changes: 4 additions & 2 deletions test/cdata-fake-end.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use strict";

require(".").test({
const { test } = require(".");

test({
name: "cdata fake end",
expect: [
["opentagstart", { name: "r", attributes: {} }],
Expand All @@ -17,7 +19,7 @@ require(".").test({
},
});

require(".").test({
test({
name: "cdata fake end 2",
expect: [
["opentagstart", { name: "r", attributes: {} }],
Expand Down
26 changes: 25 additions & 1 deletion test/cdata.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use strict";

require(".").test({
const { test } = require(".");

test({
name: "cdata",
xml: "<r><![CDATA[ this is character data  ]]><![CDATA[]]></r>",
expect: [
Expand All @@ -11,3 +13,25 @@ require(".").test({
["closetag", { name: "r", attributes: {}, isSelfClosing: false }],
],
});

test({
name: "cdata end in attribute",
expect: [
["opentagstart", { name: "r", attributes: {} }],
["opentag", {
name: "r",
attributes: {
foo: "]]>",
},
isSelfClosing: true,
}],
["closetag", {
name: "r",
attributes: {
foo: "]]>",
},
isSelfClosing: true,
}],
],
xml: "<r foo=']]>'/>",
});

0 comments on commit a7495ac

Please sign in to comment.