fast-xml-parser 4.0.10 → 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 +3 -0
- package/package.json +1 -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,8 @@
|
|
|
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
|
+
|
|
3
6
|
**4.0.10 / 2022-09-14**
|
|
4
7
|
* fix broken links in demo site (By [Yannick Lang](https://github.com/layaxx))
|
|
5
8
|
* fix #491: tagValueProcessor type definition (By [Andrea Francesco Speziale](https://github.com/andreafspeziale))
|
package/package.json
CHANGED
|
@@ -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
|
}
|