fast-xml-parser 4.3.6 → 4.4.0
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 +5 -0
- package/package.json +1 -1
- package/src/fxp.d.ts +2 -2
- package/src/validator.js +2 -0
- package/src/xmlparser/OrderedObjParser.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
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.4.0 / 2024-05-18**
|
|
4
|
+
* fix #654: parse attribute list correctly for self closing stop node.
|
|
5
|
+
* fix: validator bug when closing tag is not opened. (#647) (By [Ryosuke Fukatani](https://github.com/RyosukeFukatani))
|
|
6
|
+
* fix #581: typings; return type of `tagValueProcessor` & `attributeValueProcessor` (#582) (By [monholm]())
|
|
7
|
+
|
|
3
8
|
**4.3.6 / 2024-03-16**
|
|
4
9
|
* Add support for parsing HTML numeric entities (#645) (By [Jonas Schade ](https://github.com/DerZade))
|
|
5
10
|
|
package/package.json
CHANGED
package/src/fxp.d.ts
CHANGED
|
@@ -345,7 +345,7 @@ type XmlBuilderOptions = {
|
|
|
345
345
|
*
|
|
346
346
|
* Defaults to `(tagName, val, jPath, hasAttributes, isLeafNode) => val`
|
|
347
347
|
*/
|
|
348
|
-
tagValueProcessor?: (name: string, value: unknown) =>
|
|
348
|
+
tagValueProcessor?: (name: string, value: unknown) => unknown;
|
|
349
349
|
|
|
350
350
|
/**
|
|
351
351
|
* Control how attribute value should be parsed
|
|
@@ -358,7 +358,7 @@ type XmlBuilderOptions = {
|
|
|
358
358
|
*
|
|
359
359
|
* Defaults to `(attrName, val, jPath) => val`
|
|
360
360
|
*/
|
|
361
|
-
attributeValueProcessor?: (name: string, value: unknown) =>
|
|
361
|
+
attributeValueProcessor?: (name: string, value: unknown) => unknown;
|
|
362
362
|
|
|
363
363
|
/**
|
|
364
364
|
* Whether to process default and DOCTYPE entities
|
package/src/validator.js
CHANGED
|
@@ -103,6 +103,8 @@ exports.validate = function (xmlData, options) {
|
|
|
103
103
|
return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
|
|
104
104
|
} else if (attrStr.trim().length > 0) {
|
|
105
105
|
return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
106
|
+
} else if (tags.length === 0) {
|
|
107
|
+
return getErrorObject('InvalidTag', "Closing tag '"+tagName+"' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
106
108
|
} else {
|
|
107
109
|
const otg = tags.pop();
|
|
108
110
|
if (tagName !== otg.tagName) {
|
|
@@ -311,10 +311,18 @@ const parseXml = function(xmlData) {
|
|
|
311
311
|
let tagContent = "";
|
|
312
312
|
//self-closing tag
|
|
313
313
|
if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
|
|
314
|
+
if(tagName[tagName.length - 1] === "/"){ //remove trailing '/'
|
|
315
|
+
tagName = tagName.substr(0, tagName.length - 1);
|
|
316
|
+
jPath = jPath.substr(0, jPath.length - 1);
|
|
317
|
+
tagExp = tagName;
|
|
318
|
+
}else{
|
|
319
|
+
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
320
|
+
}
|
|
314
321
|
i = result.closeIndex;
|
|
315
322
|
}
|
|
316
323
|
//unpaired tag
|
|
317
324
|
else if(this.options.unpairedTags.indexOf(tagName) !== -1){
|
|
325
|
+
|
|
318
326
|
i = result.closeIndex;
|
|
319
327
|
}
|
|
320
328
|
//normal tag
|