fast-xml-parser 5.2.4 → 5.3.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 +7 -0
- package/lib/fxp.cjs +1 -1
- package/lib/fxp.d.cts +1 -1
- 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/package.json +1 -2
- package/src/cli/cli.js +4 -0
- package/src/fxp.d.ts +7 -7
- package/src/xmlparser/DocTypeReader.js +297 -287
- package/src/xmlparser/OrderedObjParser.js +3 -2
- package/src/xmlparser/XMLParser.js +4 -4
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import {getAllMatches, isExist} from '../util.js';
|
|
5
5
|
import xmlNode from './xmlNode.js';
|
|
6
|
-
import
|
|
6
|
+
import DocTypeReader from './DocTypeReader.js';
|
|
7
7
|
import toNumber from "strnum";
|
|
8
8
|
import getIgnoreAttributesFn from "../ignoreAttributes.js";
|
|
9
9
|
|
|
@@ -189,6 +189,7 @@ const parseXml = function(xmlData) {
|
|
|
189
189
|
let currentNode = xmlObj;
|
|
190
190
|
let textData = "";
|
|
191
191
|
let jPath = "";
|
|
192
|
+
const docTypeReader = new DocTypeReader(this.options.processEntities);
|
|
192
193
|
for(let i=0; i< xmlData.length; i++){//for each char in XML data
|
|
193
194
|
const ch = xmlData[i];
|
|
194
195
|
if(ch === '<'){
|
|
@@ -262,7 +263,7 @@ const parseXml = function(xmlData) {
|
|
|
262
263
|
}
|
|
263
264
|
i = endIndex;
|
|
264
265
|
} else if( xmlData.substr(i + 1, 2) === '!D') {
|
|
265
|
-
const result = readDocType(xmlData, i);
|
|
266
|
+
const result = docTypeReader.readDocType(xmlData, i);
|
|
266
267
|
this.docTypeEntities = result.entities;
|
|
267
268
|
i = result.i;
|
|
268
269
|
}else if(xmlData.substr(i + 1, 2) === '![') {
|
|
@@ -13,16 +13,16 @@ export default class XMLParser{
|
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Parse XML dats to JS object
|
|
16
|
-
* @param {string|
|
|
16
|
+
* @param {string|Uint8Array} xmlData
|
|
17
17
|
* @param {boolean|Object} validationOption
|
|
18
18
|
*/
|
|
19
19
|
parse(xmlData,validationOption){
|
|
20
|
-
if(typeof xmlData
|
|
21
|
-
}else if( xmlData.toString){
|
|
20
|
+
if(typeof xmlData !== "string" && xmlData.toString){
|
|
22
21
|
xmlData = xmlData.toString();
|
|
23
|
-
}else{
|
|
22
|
+
}else if(typeof xmlData !== "string"){
|
|
24
23
|
throw new Error("XML data is accepted in String or Bytes[] form.")
|
|
25
24
|
}
|
|
25
|
+
|
|
26
26
|
if( validationOption){
|
|
27
27
|
if(validationOption === true) validationOption = {}; //validate with default options
|
|
28
28
|
|