fast-xml-parser 4.0.2 → 4.0.5

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.5 / 2022-03-06**
4
+ * fix #437: call tagValueProcessor from XML builder
5
+
6
+ **4.0.4 / 2022-03-03**
7
+ * fix #435: should skip unpaired and self-closing nodes when set as stopnodes
8
+
9
+ **4.0.3 / 2022-02-15**
10
+ * fix: ReferenceError when Bundled with Strict (#431) (By [Andreas Heissenberger](https://github.com/aheissenberger))
11
+
12
+
3
13
  **4.0.2 / 2022-02-04**
4
14
  * builder supports `suppressUnpairedNode`
5
15
  * parser supports `ignoreDeclaration` and `ignorePiTags`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-xml-parser",
3
- "version": "4.0.2",
3
+ "version": "4.0.5",
4
4
  "description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
5
5
  "main": "./src/fxp.js",
6
6
  "scripts": {
@@ -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(val);
198
199
 
199
200
  if( textValue === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired
200
201
  if(this.options.suppressUnpairedNode){
@@ -72,7 +72,7 @@ function propName(obj){
72
72
  function attr_to_str(attrMap, options){
73
73
  let attrStr = "";
74
74
  if(attrMap && !options.ignoreAttributes){
75
- for( attr in attrMap){
75
+ for (let attr in attrMap){
76
76
  let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
77
77
  attrVal = replaceEntitiesValue(attrVal, options);
78
78
  if(attrVal === true && options.suppressBooleanAttributes){
@@ -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;