fast-xml-parser 4.0.3 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library.
2
2
 
3
+ **4.0.6 / 2022-03-08**
4
+ * fix: call tagValueProcessor only once for array items
5
+ * fix: missing changed for #437
6
+
7
+ **4.0.5 / 2022-03-06**
8
+ * fix #437: call tagValueProcessor from XML builder
9
+
10
+ **4.0.4 / 2022-03-03**
11
+ * fix #435: should skip unpaired and self-closing nodes when set as stopnodes
12
+
3
13
  **4.0.3 / 2022-02-15**
4
14
  * fix: ReferenceError when Bundled with Strict (#431) (By [Andreas Heissenberger](https://github.com/aheissenberger))
5
15
 
package/README.md CHANGED
@@ -18,6 +18,7 @@ Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++
18
18
 
19
19
  Check [ThankYouBackers](https://github.com/NaturalIntelligence/ThankYouBackers) for our contributors
20
20
 
21
+ [![](static/img/ni_ads_ads.gif)](https://github.com/NaturalIntelligence/ads/)
21
22
  ## Users
22
23
 
23
24
  <a href="https://github.com/renovatebot/renovate" title="renovate" ><img src="https://avatars1.githubusercontent.com/u/38656520" width="60px" ></a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-xml-parser",
3
- "version": "4.0.3",
3
+ "version": "4.0.6",
4
4
  "description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
5
5
  "main": "./src/fxp.js",
6
6
  "scripts": {
@@ -156,7 +156,7 @@ function buildAttrPairStr(attrName, val){
156
156
  function processTextOrObjNode (object, key, level) {
157
157
  const result = this.j2x(object, level + 1);
158
158
  if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) {
159
- return this.buildTextNode(result.val, key, result.attrStr, level);
159
+ return this.buildTextNode(object[this.options.textNodeName], key, result.attrStr, level);
160
160
  } else {
161
161
  return this.buildObjNode(result.val, key, result.attrStr, level);
162
162
  }
@@ -194,7 +194,8 @@ function buildEmptyObjNode(val, key, attrStr, level) {
194
194
  }
195
195
 
196
196
  function buildTextValNode(val, key, attrStr, level) {
197
- const textValue = this.replaceEntitiesValue(val);
197
+ let textValue = this.options.tagValueProcessor(key, val);
198
+ textValue = this.replaceEntitiesValue(textValue);
198
199
 
199
200
  if( textValue === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired
200
201
  if(this.options.suppressUnpairedNode){
@@ -285,9 +285,13 @@ const parseXml = function(xmlData) {
285
285
  if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) { //TODO: namespace
286
286
  let tagContent = "";
287
287
  //self-closing tag
288
- if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){}
288
+ if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
289
+ i = result.closeIndex;
290
+ }
289
291
  //boolean tag
290
- else if(this.options.unpairedTags.indexOf(tagName) !== -1){}
292
+ else if(this.options.unpairedTags.indexOf(tagName) !== -1){
293
+ i = result.closeIndex;
294
+ }
291
295
  //normal tag
292
296
  else{
293
297
  //read until closing tag is found
@@ -312,7 +316,6 @@ const parseXml = function(xmlData) {
312
316
  }else{
313
317
  //selfClosing tag
314
318
  if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
315
-
316
319
  if(tagName[tagName.length - 1] === "/"){ //remove trailing '/'
317
320
  tagName = tagName.substr(0, tagName.length - 1);
318
321
  tagExp = tagName;