node-xml-stream-parser
Advanced tools
Comparing version
@@ -145,3 +145,3 @@ "use strict"; | ||
case STATE.CDATA: | ||
if (prev === "]" && c === "]") this._onCDATAEnd(); | ||
if (this.buffer[this.pos - 3] === "]" && prev === "]" && c === ">") this._onCDATAEnd(); | ||
break; | ||
@@ -243,3 +243,3 @@ | ||
var text = this._endRecording(); // Will return CDATA[XXX] we regexp out the actual text in the CDATA. | ||
text = text.slice(text.indexOf("[") + 1, text.lastIndexOf("]")); | ||
text = text.slice(text.indexOf("[") + 1, text.lastIndexOf("]>") - 1); | ||
this.state = STATE.TEXT; | ||
@@ -246,0 +246,0 @@ |
@@ -124,6 +124,19 @@ "use strict"; | ||
p.write("<root><![CDATA[<p>cdata-text</br></p>]]</root>"); | ||
p.write("<root><![CDATA[<p>cdata-text</br></p>]]></root>"); | ||
}); | ||
}); | ||
describe("Emit CDATA with square-bracket text", function () { | ||
it("#on(cdata)", function (done) { | ||
var p = new _index2.default(); | ||
p.on("cdata", function (cdata) { | ||
(0, _chai.expect)(cdata).to.eql("<p>cdata-text with some square-bracket-wrapped text [[12345]]</br></p>"); | ||
done(); | ||
}); | ||
p.write("<root><![CDATA[<p>cdata-text with some square-bracket-wrapped text [[12345]]</br></p>]]></root>"); | ||
}); | ||
}); | ||
describe("Ignore comments", function () { | ||
@@ -130,0 +143,0 @@ it("#on(text) with comments", function (done) { |
{ | ||
"name": "node-xml-stream-parser", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "A fast XML parser using streams.", | ||
@@ -26,2 +26,5 @@ "main": "dist/index.js", | ||
"name": "Mario Fahlandt" | ||
}, | ||
{ | ||
"name": "Markus Velten" | ||
} | ||
@@ -32,3 +35,3 @@ ], | ||
"type": "git", | ||
"url": "https://github.com/mfahlandt/node-xml-stream" | ||
"url": "https://github.com/slippyex/node-xml-stream" | ||
}, | ||
@@ -35,0 +38,0 @@ "devDependencies": { |
@@ -117,5 +117,5 @@ # node-xml-stream | ||
### Contributing | ||
Pull requests and stars always welcome. For bugs and feature requests, please [create an issue.](https://github.com/mfahlandt/node-xml-stream-parser/issues) | ||
Pull requests and stars always welcome. For bugs and feature requests, please [create an issue.](https://github.com/slippyex/node-xml-stream-parser/issues) | ||
### License | ||
MIT |
Sorry, the diff of this file is not supported yet
90531
0.59%18
5.88%428
2.39%