fast-xml-parser 4.2.0 → 4.2.2
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 +6 -0
- package/package.json +6 -3
- package/src/xmlparser/OrderedObjParser.js +20 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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.2.2 / 2023-04-18**
|
|
4
|
+
* fix #562: fix unpaired tag when it comes in last of a nested tag. Also throw error when unpaired tag is used as closing tag
|
|
5
|
+
|
|
6
|
+
**4.2.1 / 2023-04-18**
|
|
7
|
+
* fix: jpath after unpaired tags
|
|
8
|
+
|
|
3
9
|
**4.2.0 / 2023-04-09**
|
|
4
10
|
* support `updateTag` parser property
|
|
5
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-xml-parser",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
|
|
5
5
|
"main": "./src/fxp.js",
|
|
6
6
|
"scripts": {
|
|
@@ -58,10 +58,13 @@
|
|
|
58
58
|
"webpack-cli": "^4.9.1"
|
|
59
59
|
},
|
|
60
60
|
"typings": "src/fxp.d.ts",
|
|
61
|
-
"funding": {
|
|
61
|
+
"funding": [{
|
|
62
62
|
"type": "paypal",
|
|
63
63
|
"url": "https://paypal.me/naturalintelligence"
|
|
64
|
-
},
|
|
64
|
+
},{
|
|
65
|
+
"type": "github",
|
|
66
|
+
"url": "https://github.com/sponsors/NaturalIntelligence"
|
|
67
|
+
}],
|
|
65
68
|
"dependencies": {
|
|
66
69
|
"strnum": "^1.0.5"
|
|
67
70
|
}
|
|
@@ -206,8 +206,20 @@ const parseXml = function(xmlData) {
|
|
|
206
206
|
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
//check if last tag of nested tag was unpaired tag
|
|
210
|
+
const lastTagName = jPath.substring(jPath.lastIndexOf(".")+1);
|
|
211
|
+
if(tagName && this.options.unpairedTags.indexOf(tagName) !== -1 ){
|
|
212
|
+
throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
|
|
213
|
+
}
|
|
214
|
+
let propIndex = 0
|
|
215
|
+
if(lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1 ){
|
|
216
|
+
propIndex = jPath.lastIndexOf('.', jPath.lastIndexOf('.')-1)
|
|
217
|
+
this.tagsNodeStack.pop();
|
|
218
|
+
}else{
|
|
219
|
+
propIndex = jPath.lastIndexOf(".");
|
|
220
|
+
}
|
|
221
|
+
jPath = jPath.substring(0, propIndex);
|
|
222
|
+
|
|
211
223
|
currentNode = this.tagsNodeStack.pop();//avoid recursion, set the parent tag scope
|
|
212
224
|
textData = "";
|
|
213
225
|
i = closeIndex;
|
|
@@ -284,23 +296,22 @@ const parseXml = function(xmlData) {
|
|
|
284
296
|
}
|
|
285
297
|
}
|
|
286
298
|
|
|
287
|
-
if(tagName !== xmlObj.tagname){
|
|
288
|
-
jPath += jPath ? "." + tagName : tagName;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
299
|
//check if last tag was unpaired tag
|
|
292
300
|
const lastTag = currentNode;
|
|
293
301
|
if(lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1 ){
|
|
294
302
|
currentNode = this.tagsNodeStack.pop();
|
|
303
|
+
jPath = jPath.substring(0, jPath.lastIndexOf("."));
|
|
304
|
+
}
|
|
305
|
+
if(tagName !== xmlObj.tagname){
|
|
306
|
+
jPath += jPath ? "." + tagName : tagName;
|
|
295
307
|
}
|
|
296
|
-
|
|
297
308
|
if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) { //TODO: namespace
|
|
298
309
|
let tagContent = "";
|
|
299
310
|
//self-closing tag
|
|
300
311
|
if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
|
|
301
312
|
i = result.closeIndex;
|
|
302
313
|
}
|
|
303
|
-
//
|
|
314
|
+
//unpaired tag
|
|
304
315
|
else if(this.options.unpairedTags.indexOf(tagName) !== -1){
|
|
305
316
|
i = result.closeIndex;
|
|
306
317
|
}
|
|
@@ -343,8 +354,8 @@ const parseXml = function(xmlData) {
|
|
|
343
354
|
if(tagName !== tagExp && attrExpPresent){
|
|
344
355
|
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
345
356
|
}
|
|
346
|
-
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
347
357
|
this.addChild(currentNode, childNode, jPath)
|
|
358
|
+
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
348
359
|
}
|
|
349
360
|
//opening tag
|
|
350
361
|
else{
|