fast-xml-parser 4.0.9 → 4.0.11
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 +9 -0
- package/README.md +3 -4
- package/package.json +2 -2
- package/src/fxp.d.ts +9 -1
- package/src/xmlparser/OrderedObjParser.js +3 -1
- package/src/xmlparser/XMLParser.js +2 -0
- package/src/fxp_cjs +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
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.11 / 2022-10-05**
|
|
4
|
+
* fix #501: parse for entities only once
|
|
5
|
+
|
|
6
|
+
**4.0.10 / 2022-09-14**
|
|
7
|
+
* fix broken links in demo site (By [Yannick Lang](https://github.com/layaxx))
|
|
8
|
+
* fix #491: tagValueProcessor type definition (By [Andrea Francesco Speziale](https://github.com/andreafspeziale))
|
|
9
|
+
* Add jsdocs for tagValueProcessor
|
|
10
|
+
|
|
11
|
+
|
|
3
12
|
**4.0.9 / 2022-07-10**
|
|
4
13
|
* fix #470: stop-tag can have self-closing tag with same name
|
|
5
14
|
* fix #472: stopNode can have any special tag inside
|
package/README.md
CHANGED
|
@@ -34,7 +34,6 @@ Check [ThankYouBackers](https://github.com/NaturalIntelligence/ThankYouBackers)
|
|
|
34
34
|
<a href="https://github.com/prettier" title="Prettier" > <img src="https://avatars0.githubusercontent.com/u/25822731" width="60px" ></a>
|
|
35
35
|
<a href="http://brain.js.org/" title="brain.js" > <img src="https://avatars2.githubusercontent.com/u/23732838" width="60px" ></a>
|
|
36
36
|
<a href="https://github.com/aws" title="AWS SDK" > <img src="https://avatars.githubusercontent.com/u/2232217" width="60px" ></a>
|
|
37
|
-
<a href="#" title="NHS Connect" > <img src="https://avatars3.githubusercontent.com/u/20316669" width="60px" ></a>
|
|
38
37
|
<a href="http://www.fda.gov/" title="Food and Drug Administration " > <img src="https://avatars2.githubusercontent.com/u/6471964" width="60px" ></a>
|
|
39
38
|
<a href="http://www.magento.com/" title="Magento" > <img src="https://avatars2.githubusercontent.com/u/168457" width="60px" ></a>
|
|
40
39
|
|
|
@@ -50,7 +49,7 @@ Check the list of all known users [here](./USERs.md);
|
|
|
50
49
|
* Parse XML to JS Object
|
|
51
50
|
* Build XML from JS Object
|
|
52
51
|
* Works with node packages, in browser, and in CLI (press try me button above for demo)
|
|
53
|
-
* Faster than any pure JS implementation.
|
|
52
|
+
* Faster than any other pure JS implementation.
|
|
54
53
|
* It can handle big files (tested up to 100mb).
|
|
55
54
|
* Controlled parsing using various options
|
|
56
55
|
* XML Entities, HTML entities, and DOCTYPE entites are supported.
|
|
@@ -121,7 +120,7 @@ Check lib folder for different browser bundles
|
|
|
121
120
|
2. [XML Parser](./docs/v4/2.XMLparseOptions.md)
|
|
122
121
|
3. [XML Builder](./docs/v4/3.XMLBuilder.md)
|
|
123
122
|
4. [XML Validator](./docs/v4/4.XMLValidator.md)
|
|
124
|
-
5. [
|
|
123
|
+
5. [Entities](./docs/v4/5.Entities.md)
|
|
125
124
|
6. [HTML Document Parsing](./docs/v4/6.HTMLParsing.md)
|
|
126
125
|
7. [PI Tag processing](./docs/v4/7.PITags.md)
|
|
127
126
|
## Performance
|
|
@@ -191,4 +190,4 @@ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com
|
|
|
191
190
|
# License
|
|
192
191
|
* MIT License
|
|
193
192
|
|
|
194
|
-

|
|
193
|
+

|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fast-xml-parser",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11",
|
|
4
4
|
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
|
|
5
5
|
"main": "./src/fxp.js",
|
|
6
6
|
"scripts": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"jasmine": "^3.6.4",
|
|
54
54
|
"nyc": "^15.1.0",
|
|
55
55
|
"prettier": "^1.19.1",
|
|
56
|
-
"publish-please": "^
|
|
56
|
+
"publish-please": "^2.4.1",
|
|
57
57
|
"webpack": "^5.64.4",
|
|
58
58
|
"webpack-cli": "^4.9.1"
|
|
59
59
|
},
|
package/src/fxp.d.ts
CHANGED
|
@@ -11,7 +11,15 @@ type X2jOptions = {
|
|
|
11
11
|
trimValues: boolean;
|
|
12
12
|
cdataPropName: false | string;
|
|
13
13
|
commentPropName: false | string;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
Control how tag value should be parsed. Called only if tag value is not empty
|
|
16
|
+
|
|
17
|
+
@returns {undefined|null} `undefined` or `null` to set original value.
|
|
18
|
+
@returns {unknown}
|
|
19
|
+
1. Different value or value with different data type to set new value. <br>
|
|
20
|
+
2. Same value to set parsed value if `parseTagValue: true`.
|
|
21
|
+
*/
|
|
22
|
+
tagValueProcessor: (tagName: string, tagValue: string, jPath: string, hasAttributes: boolean, isLeafNode: boolean) => unknown;
|
|
15
23
|
attributeValueProcessor: (attrName: string, attrValue: string, jPath: string) => string;
|
|
16
24
|
numberParseOptions: strnumOptions;
|
|
17
25
|
stopNodes: string[];
|
|
@@ -20,12 +20,12 @@ class OrderedObjParser{
|
|
|
20
20
|
this.tagsNodeStack = [];
|
|
21
21
|
this.docTypeEntities = {};
|
|
22
22
|
this.lastEntities = {
|
|
23
|
-
"amp" : { regex: /&(amp|#38|#x26);/g, val : "&"},
|
|
24
23
|
"apos" : { regex: /&(apos|#39|#x27);/g, val : "'"},
|
|
25
24
|
"gt" : { regex: /&(gt|#62|#x3E);/g, val : ">"},
|
|
26
25
|
"lt" : { regex: /&(lt|#60|#x3C);/g, val : "<"},
|
|
27
26
|
"quot" : { regex: /&(quot|#34|#x22);/g, val : "\""},
|
|
28
27
|
};
|
|
28
|
+
this.ampEntity = { regex: /&(amp|#38|#x26);/g, val : "&"};
|
|
29
29
|
this.htmlEntities = {
|
|
30
30
|
"space": { regex: /&(nbsp|#160);/g, val: " " },
|
|
31
31
|
// "lt" : { regex: /&(lt|#60);/g, val: "<" },
|
|
@@ -364,6 +364,7 @@ const parseXml = function(xmlData) {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
const replaceEntitiesValue = function(val){
|
|
367
|
+
|
|
367
368
|
if(this.options.processEntities){
|
|
368
369
|
for(let entityName in this.docTypeEntities){
|
|
369
370
|
const entity = this.docTypeEntities[entityName];
|
|
@@ -379,6 +380,7 @@ const replaceEntitiesValue = function(val){
|
|
|
379
380
|
val = val.replace( entity.regex, entity.val);
|
|
380
381
|
}
|
|
381
382
|
}
|
|
383
|
+
val = val.replace( this.ampEntity.regex, this.ampEntity.val);
|
|
382
384
|
}
|
|
383
385
|
return val;
|
|
384
386
|
}
|
|
@@ -47,6 +47,8 @@ class XMLParser{
|
|
|
47
47
|
throw new Error("Entity value can't have '&'")
|
|
48
48
|
}else if(key.indexOf("&") !== -1 || key.indexOf(";") !== -1){
|
|
49
49
|
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'")
|
|
50
|
+
}else if(value === "&"){
|
|
51
|
+
throw new Error("An entity with value '&' is not permitted");
|
|
50
52
|
}else{
|
|
51
53
|
this.externalEntities[key] = value;
|
|
52
54
|
}
|