Skip to content

Commit ce3df9c

Browse files
committed
fix NaturalIntelligence#128 : use 'attrValueProcessor' to process attribute value in json2xml parser
1 parent a5fe74b commit ce3df9c

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
3.12.8 / 2018-11-22
2+
* fix #128 : use 'attrValueProcessor' to process attribute value in json2xml parser
13
3.12.6 / 2018-11-10
24
* Fix #126: check for type
35
3.12.4 / 2018-09-12

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fast-xml-parser",
3-
"version": "3.12.7",
3+
"version": "3.12.8",
44
"description": "Validate XML or Parse XML to JS/JSON very fast without C/C++ based libraries",
55
"main": "./src/parser.js",
66
"scripts": {

spec/j2x_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ describe("XMLParser", function() {
250250
attrNodeName: "@",
251251
encodeHTMLchar: true,
252252
tagValueProcessor: a=> he.encode(a, { useNamedReferences: true}),
253-
attrValueProcessor: a=> he.encode(a, {isAttributeValue: isAttribute, useNamedReferences: true})
253+
attrValueProcessor: a=> he.encode(a, {isAttributeValue: true, useNamedReferences: true})
254254
});
255255
const result = parser.parse(jObj);
256256
//console.log(result);
@@ -301,7 +301,7 @@ describe("XMLParser", function() {
301301
encodeHTMLchar: true,
302302
supressEmptyNode: true,
303303
tagValueProcessor: a=> he.encode(a, { useNamedReferences: true}),
304-
attrValueProcessor: a=> he.encode(a, {isAttributeValue: isAttribute, useNamedReferences: true})
304+
attrValueProcessor: a=> he.encode(a, {isAttributeValue: true, useNamedReferences: true})
305305
});
306306
const result = parser.parse(jObj);
307307
//console.log(result);
@@ -339,7 +339,7 @@ describe("XMLParser", function() {
339339
encodeHTMLchar: true,
340340
format: true,
341341
tagValueProcessor: a=> he.encode(a, { useNamedReferences: true}),
342-
attrValueProcessor: a=> he.encode(a, {isAttributeValue: isAttribute, useNamedReferences: true})
342+
attrValueProcessor: a=> he.encode(a, {isAttributeValue: true, useNamedReferences: true})
343343
});
344344
const result = parser.parse(jObj);
345345
const expected = `<a b="val&gt;1" c="val&lt;2">

src/json2xml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Parser.prototype.j2x = function(jObj, level) {
134134
const Ks = Object.keys(jObj[key]);
135135
const L = Ks.length;
136136
for (let j = 0; j < L; j++) {
137-
attrStr += " " + Ks[j] + "=\"" + this.options.tagValueProcessor("" + jObj[key][Ks[j]]) + "\"";
137+
attrStr += " " + Ks[j] + "=\"" + this.options.attrValueProcessor("" + jObj[key][Ks[j]]) + "\"";
138138
}
139139
} else {
140140
const result = this.j2x(jObj[key], level + 1);

0 commit comments

Comments
 (0)