diff --git a/spec/cdata_spec.js b/spec/cdata_spec.js
index 3c0e872..3742edf 100644
--- a/spec/cdata_spec.js
+++ b/spec/cdata_spec.js
@@ -446,4 +446,20 @@ patronymic`;
// console.log(JSON.stringify(result,null,4));
expect(result).toEqual(expected);
});
+
+ it("should not process entities in CDATA", function() {
+ const xmlData =``;
+
+ const expected = { xml: '<text>' };
+
+ const options = {
+ ignoreAttributes: false,
+ };
+
+ const parser = new XMLParser(options);
+ let result = parser.parse(xmlData);
+
+ // console.log(JSON.stringify(result,null,4));
+ expect(result).toEqual(expected);
+ });
});
diff --git a/spec/entities_spec.js b/spec/entities_spec.js
index 41ef08a..c87ced6 100644
--- a/spec/entities_spec.js
+++ b/spec/entities_spec.js
@@ -27,7 +27,7 @@ describe("XMLParser Entities", function() {
"a:b": 2,
"a-b:b-a": 2,
"a:c": "test&\nтест<\ntest",
- "a:el": "<2]]]]>&a",
+ "a:el": "<<b>2]]]]>&a",
"c:string": {
"#text": "страхования » от суммы его активов",
"@_lang": "ru"
diff --git a/src/xmlparser/OrderedObjParser.js b/src/xmlparser/OrderedObjParser.js
index fafc680..75d9718 100644
--- a/src/xmlparser/OrderedObjParser.js
+++ b/src/xmlparser/OrderedObjParser.js
@@ -265,14 +265,13 @@ const parseXml = function(xmlData) {
textData = this.saveTextToParentTag(textData, currentNode, jPath);
+ let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
+ if(val == undefined) val = "";
+
//cdata should be set even if it is 0 length string
if(this.options.cdataPropName){
- // let val = this.parseTextData(tagExp, this.options.cdataPropName, jPath + "." + this.options.cdataPropName, true, false, true);
- // if(!val) val = "";
currentNode.add(this.options.cdataPropName, [ { [this.options.textNodeName] : tagExp } ]);
}else{
- let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true);
- if(val == undefined) val = "";
currentNode.add(this.options.textNodeName, val);
}