fast-xml-parser 5.3.5 → 5.3.7
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 +12 -0
- package/lib/fxbuilder.min.js +1 -1
- package/lib/fxbuilder.min.js.map +1 -1
- package/lib/fxp.cjs +1 -1
- package/lib/fxp.d.cts +75 -12
- package/lib/fxp.min.js +1 -1
- package/lib/fxp.min.js.map +1 -1
- package/lib/fxparser.min.js +1 -1
- package/lib/fxparser.min.js.map +1 -1
- package/lib/fxvalidator.min.js +1 -1
- package/lib/fxvalidator.min.js.map +1 -1
- package/package.json +4 -4
- package/src/fxp.d.ts +74 -12
- package/src/util.js +1 -26
- package/src/xmlparser/DocTypeReader.js +63 -53
- package/src/xmlparser/OptionsBuilder.js +84 -44
- package/src/xmlparser/OrderedObjParser.js +254 -187
|
@@ -1,46 +1,86 @@
|
|
|
1
|
-
|
|
2
1
|
export const defaultOptions = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const buildOptions = function(options) {
|
|
45
|
-
return Object.assign({}, defaultOptions, options);
|
|
2
|
+
preserveOrder: false,
|
|
3
|
+
attributeNamePrefix: '@_',
|
|
4
|
+
attributesGroupName: false,
|
|
5
|
+
textNodeName: '#text',
|
|
6
|
+
ignoreAttributes: true,
|
|
7
|
+
removeNSPrefix: false, // remove NS from tag name or attribute name if true
|
|
8
|
+
allowBooleanAttributes: false, //a tag can have attributes without any value
|
|
9
|
+
//ignoreRootElement : false,
|
|
10
|
+
parseTagValue: true,
|
|
11
|
+
parseAttributeValue: false,
|
|
12
|
+
trimValues: true, //Trim string values of tag and attributes
|
|
13
|
+
cdataPropName: false,
|
|
14
|
+
numberParseOptions: {
|
|
15
|
+
hex: true,
|
|
16
|
+
leadingZeros: true,
|
|
17
|
+
eNotation: true
|
|
18
|
+
},
|
|
19
|
+
tagValueProcessor: function (tagName, val) {
|
|
20
|
+
return val;
|
|
21
|
+
},
|
|
22
|
+
attributeValueProcessor: function (attrName, val) {
|
|
23
|
+
return val;
|
|
24
|
+
},
|
|
25
|
+
stopNodes: [], //nested tags will not be parsed even for errors
|
|
26
|
+
alwaysCreateTextNode: false,
|
|
27
|
+
isArray: () => false,
|
|
28
|
+
commentPropName: false,
|
|
29
|
+
unpairedTags: [],
|
|
30
|
+
processEntities: true,
|
|
31
|
+
htmlEntities: false,
|
|
32
|
+
ignoreDeclaration: false,
|
|
33
|
+
ignorePiTags: false,
|
|
34
|
+
transformTagName: false,
|
|
35
|
+
transformAttributeName: false,
|
|
36
|
+
updateTag: function (tagName, jPath, attrs) {
|
|
37
|
+
return tagName
|
|
38
|
+
},
|
|
39
|
+
// skipEmptyListItem: false
|
|
40
|
+
captureMetaData: false,
|
|
46
41
|
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Normalizes processEntities option for backward compatibility
|
|
45
|
+
* @param {boolean|object} value
|
|
46
|
+
* @returns {object} Always returns normalized object
|
|
47
|
+
*/
|
|
48
|
+
function normalizeProcessEntities(value) {
|
|
49
|
+
// Boolean backward compatibility
|
|
50
|
+
if (typeof value === 'boolean') {
|
|
51
|
+
return {
|
|
52
|
+
enabled: value, // true or false
|
|
53
|
+
maxEntitySize: 10000,
|
|
54
|
+
maxExpansionDepth: 10,
|
|
55
|
+
maxTotalExpansions: 1000,
|
|
56
|
+
maxExpandedLength: 100000,
|
|
57
|
+
allowedTags: null,
|
|
58
|
+
tagFilter: null
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Object config - merge with defaults
|
|
63
|
+
if (typeof value === 'object' && value !== null) {
|
|
64
|
+
return {
|
|
65
|
+
enabled: value.enabled !== false, // default true if not specified
|
|
66
|
+
maxEntitySize: value.maxEntitySize ?? 10000,
|
|
67
|
+
maxExpansionDepth: value.maxExpansionDepth ?? 10,
|
|
68
|
+
maxTotalExpansions: value.maxTotalExpansions ?? 1000,
|
|
69
|
+
maxExpandedLength: value.maxExpandedLength ?? 100000,
|
|
70
|
+
allowedTags: value.allowedTags ?? null,
|
|
71
|
+
tagFilter: value.tagFilter ?? null
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Default to enabled with limits
|
|
76
|
+
return normalizeProcessEntities(true);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const buildOptions = function (options) {
|
|
80
|
+
const built = Object.assign({}, defaultOptions, options);
|
|
81
|
+
|
|
82
|
+
// Always normalize processEntities for backward compatibility and validation
|
|
83
|
+
built.processEntities = normalizeProcessEntities(built.processEntities);
|
|
84
|
+
//console.debug(built.processEntities)
|
|
85
|
+
return built;
|
|
86
|
+
};
|