fast-xml-parser 4.0.10 → 4.0.12
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/README.md +5 -2
- package/package.json +1 -1
- package/src/fxp.d.ts +3 -3
- 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,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.0.12 / 2022-11-19**
|
|
4
|
+
* fix typescript
|
|
5
|
+
|
|
6
|
+
**4.0.11 / 2022-10-05**
|
|
7
|
+
* fix #501: parse for entities only once
|
|
8
|
+
|
|
3
9
|
**4.0.10 / 2022-09-14**
|
|
4
10
|
* fix broken links in demo site (By [Yannick Lang](https://github.com/layaxx))
|
|
5
11
|
* fix #491: tagValueProcessor type definition (By [Andrea Francesco Speziale](https://github.com/andreafspeziale))
|
package/README.md
CHANGED
|
@@ -128,13 +128,16 @@ Check lib folder for different browser bundles
|
|
|
128
128
|
### XML Parser
|
|
129
129
|
|
|
130
130
|

|
|
131
|
-
|
|
131
|
+
* Y-axis: requests per second
|
|
132
|
+
* X-axis: File size
|
|
132
133
|
**Large files**
|
|
133
134
|

|
|
134
|
-
|
|
135
|
+
* Y-axis: requests per second
|
|
136
|
+
* X-axis: File size
|
|
135
137
|
### XML Builder
|
|
136
138
|
|
|
137
139
|

|
|
140
|
+
* Y-axis: requests per second
|
|
138
141
|
|
|
139
142
|
<small>negative means error</small>
|
|
140
143
|
|
package/package.json
CHANGED
package/src/fxp.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ Control how tag value should be parsed. Called only if tag value is not empty
|
|
|
20
20
|
2. Same value to set parsed value if `parseTagValue: true`.
|
|
21
21
|
*/
|
|
22
22
|
tagValueProcessor: (tagName: string, tagValue: string, jPath: string, hasAttributes: boolean, isLeafNode: boolean) => unknown;
|
|
23
|
-
attributeValueProcessor: (attrName: string, attrValue: string, jPath: string) =>
|
|
23
|
+
attributeValueProcessor: (attrName: string, attrValue: string, jPath: string) => unknown;
|
|
24
24
|
numberParseOptions: strnumOptions;
|
|
25
25
|
stopNodes: string[];
|
|
26
26
|
unpairedTags: string[];
|
|
@@ -60,8 +60,8 @@ type XmlBuilderOptions = {
|
|
|
60
60
|
preserveOrder: boolean;
|
|
61
61
|
unpairedTags: string[];
|
|
62
62
|
stopNodes: string[];
|
|
63
|
-
tagValueProcessor: (name: string, value:
|
|
64
|
-
attributeValueProcessor: (name: string, value:
|
|
63
|
+
tagValueProcessor: (name: string, value: unknown) => string;
|
|
64
|
+
attributeValueProcessor: (name: string, value: unknown) => string;
|
|
65
65
|
processEntities: boolean;
|
|
66
66
|
};
|
|
67
67
|
type XmlBuilderOptionsOptional = Partial<XmlBuilderOptions>;
|
|
@@ -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
|
}
|