nuxt-ignis 0.5.0-rc.2 → 0.5.1
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/.data/content/contents.sqlite +0 -0
- package/.nuxt/components.d.ts +402 -208
- package/.nuxt/content/components.ts +201 -104
- package/.nuxt/dev/index.mjs +1041 -712
- package/.nuxt/dev/index.mjs.map +1 -1
- package/.nuxt/dist/server/client.manifest.mjs +1 -18
- package/.nuxt/dist/server/client.precomputed.mjs +1 -0
- package/.nuxt/eslint-typegen.d.ts +56 -2
- package/.nuxt/eslint.config.d.mts +2 -2
- package/.nuxt/eslint.config.mjs +10 -10
- package/.nuxt/imports.d.ts +63 -59
- package/.nuxt/manifest/latest.json +1 -1
- package/.nuxt/manifest/meta/dev.json +1 -1
- package/.nuxt/mdc-highlighter.mjs +4 -0
- package/.nuxt/mdc-image-component.mjs +1 -1
- package/.nuxt/module/nuxt-robots.d.ts +12 -12
- package/.nuxt/module/nuxt-seo-utils.d.ts +10 -10
- package/.nuxt/module/nuxt-site-config.d.ts +8 -8
- package/.nuxt/module/nuxt-sitemap.d.ts +17 -17
- package/.nuxt/nitro.json +4 -4
- package/.nuxt/nuxt.d.ts +12 -11
- package/.nuxt/nuxt.json +2 -2
- package/.nuxt/nuxt.node.d.ts +13 -10
- package/.nuxt/tsconfig.app.json +191 -191
- package/.nuxt/tsconfig.json +194 -194
- package/.nuxt/tsconfig.node.json +105 -105
- package/.nuxt/tsconfig.server.json +128 -128
- package/.nuxt/tsconfig.shared.json +55 -55
- package/.nuxt/types/build.d.ts +2 -1
- package/.nuxt/types/components.d.ts +402 -208
- package/.nuxt/types/i18n-plugin.d.ts +2 -2
- package/.nuxt/types/imports.d.ts +348 -342
- package/.nuxt/types/modules.d.ts +16 -16
- package/.nuxt/types/nitro-imports.d.ts +68 -68
- package/.nuxt/types/nitro-nuxt.d.ts +1 -0
- package/.nuxt/types/nitro-routes.d.ts +20 -20
- package/.nuxt/types/plugins.d.ts +37 -37
- package/.nuxt/types/ui.d.ts +3 -3
- package/.nuxt/ui/drawer.ts +23 -0
- package/.nuxt/ui/progress.ts +3 -3
- package/.nuxt/ui-image-component.ts +1 -1
- package/.output/nitro.json +3 -3
- package/.output/public/_nuxt/1vOq3xiE.js +1 -0
- package/.output/public/_nuxt/22rhGZdI.js +1 -0
- package/.output/public/_nuxt/9eIdSibD.js +1 -0
- package/.output/public/_nuxt/BBmTy930.js +35 -0
- package/.output/public/_nuxt/BKe83Cjx.js +1 -0
- package/.output/public/_nuxt/Bc5GLloR.js +1 -0
- package/.output/public/_nuxt/BdG3SY-u.js +1 -0
- package/.output/public/_nuxt/BeyOQpYA.js +1 -0
- package/.output/public/_nuxt/BqcXd3MY.js +94 -0
- package/.output/public/_nuxt/Bz55A4y1.js +1 -0
- package/.output/public/_nuxt/C2ybsIQ4.js +1 -0
- package/.output/public/_nuxt/C4U5VOMJ.js +1 -0
- package/.output/public/_nuxt/CAJsyjAK.js +1 -0
- package/.output/public/_nuxt/CD9aBAuy.js +1 -0
- package/.output/public/_nuxt/CHOS7x_d.js +1 -0
- package/.output/public/_nuxt/CXhUbdF6.js +1 -0
- package/.output/public/_nuxt/CZWScI5k.js +1 -0
- package/.output/public/_nuxt/DHd34syF.js +1 -0
- package/.output/public/_nuxt/DMbgtwAJ.js +1 -0
- package/.output/public/_nuxt/DR8jhnFO.js +1 -0
- package/.output/public/_nuxt/DTT0LBLY.js +1 -0
- package/.output/public/_nuxt/{aetvq4w9.js → DWV_uL6G.js} +9 -12
- package/.output/public/_nuxt/DdpTKqR-.js +1 -0
- package/.output/public/_nuxt/Df_NcBcC.js +1 -0
- package/.output/public/_nuxt/DhqOMFXQ.js +1 -0
- package/.output/public/_nuxt/Dnp9eFDR.js +1 -0
- package/.output/public/_nuxt/DnqMs_6O.js +1 -0
- package/.output/public/_nuxt/Dq7g_IfY.js +1 -0
- package/.output/public/_nuxt/DsAJWnuW.js +1 -0
- package/.output/public/_nuxt/DvVg7vM_.js +1 -0
- package/.output/public/_nuxt/DwKqLVGx.js +1 -0
- package/.output/public/_nuxt/DxzqnQKF.js +1 -0
- package/.output/public/_nuxt/Y0f1tU-r.js +1 -0
- package/.output/public/_nuxt/atySmcu6.js +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/7bab2b8f-93ee-4f44-a604-8cd2b41eac60.json +1 -0
- package/.output/public/_nuxt/entry.CtpkPzPO.css +1 -0
- package/.output/public/_nuxt/error-404.DzDu4Ean.css +1 -0
- package/.output/public/_nuxt/error-500.BdNqqJx7.css +1 -0
- package/.output/public/_nuxt/q3i45eMH.js +1 -0
- package/.output/public/_nuxt/vueform.CkWb7x1C.css +1 -0
- package/.output/server/chunks/_/error-500.mjs +1 -1
- package/.output/server/chunks/_/error-500.mjs.map +1 -1
- package/.output/server/chunks/_/nitro.mjs +468 -543
- package/.output/server/chunks/_/nitro.mjs.map +1 -1
- package/.output/server/chunks/build/client.precomputed.mjs +4 -0
- package/.output/server/chunks/build/client.precomputed.mjs.map +1 -0
- package/.output/server/chunks/routes/renderer.mjs +10 -33
- package/.output/server/chunks/routes/renderer.mjs.map +1 -1
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@babel/parser/lib/index.js +212 -145
- package/.output/server/node_modules/@babel/parser/package.json +3 -3
- package/.output/server/node_modules/@poppinss/utils/package.json +1 -1
- package/.output/server/node_modules/@shikijs/core/package.json +2 -2
- package/.output/server/node_modules/@shikijs/engine-javascript/package.json +2 -2
- package/.output/server/node_modules/@shikijs/engine-oniguruma/package.json +2 -2
- package/.output/server/node_modules/@shikijs/langs/dist/javascript.mjs +1 -1
- package/.output/server/node_modules/@shikijs/langs/dist/typescript.mjs +1 -1
- package/.output/server/node_modules/@shikijs/langs/package.json +11 -3
- package/.output/server/node_modules/@shikijs/themes/package.json +3 -3
- package/.output/server/node_modules/@shikijs/transformers/package.json +3 -3
- package/.output/server/node_modules/@shikijs/types/package.json +1 -1
- package/.output/server/node_modules/detect-libc/lib/detect-libc.js +59 -13
- package/.output/server/node_modules/detect-libc/lib/elf.js +39 -0
- package/.output/server/node_modules/detect-libc/lib/filesystem.js +18 -8
- package/.output/server/node_modules/detect-libc/package.json +5 -2
- package/.output/server/node_modules/devalue/package.json +1 -1
- package/.output/server/node_modules/devalue/src/parse.js +7 -1
- package/.output/server/node_modules/devalue/src/uneval.js +9 -8
- package/.output/server/node_modules/fast-xml-parser/package.json +1 -1
- package/.output/server/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +297 -287
- package/.output/server/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +3 -2
- package/.output/server/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +4 -4
- package/.output/server/node_modules/image-meta/dist/index.mjs +85 -4
- package/.output/server/node_modules/image-meta/package.json +12 -12
- package/.output/server/node_modules/is-arrayish/package.json +1 -1
- package/.output/server/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +2 -2
- package/.output/server/node_modules/node-fetch-native/dist/node.mjs +10 -10
- package/.output/server/node_modules/node-fetch-native/package.json +13 -13
- package/.output/server/node_modules/node-mock-http/dist/index.mjs +1 -1
- package/.output/server/node_modules/node-mock-http/package.json +6 -6
- package/.output/server/node_modules/oauth4webapi/build/index.js +10 -8
- package/.output/server/node_modules/oauth4webapi/package.json +12 -12
- package/.output/server/node_modules/openid-client/build/index.js +1 -1
- package/.output/server/node_modules/openid-client/package.json +7 -7
- package/.output/server/node_modules/secure-json-parse/index.js +35 -0
- package/.output/server/node_modules/secure-json-parse/package.json +2 -3
- package/.output/server/node_modules/semver/classes/semver.js +19 -5
- package/.output/server/node_modules/semver/internal/identifiers.js +4 -0
- package/.output/server/node_modules/semver/package.json +3 -3
- package/.output/server/node_modules/shiki/package.json +9 -9
- package/.output/server/node_modules/simple-swizzle/package.json +1 -1
- package/.output/server/node_modules/unhead/dist/parser.mjs +508 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +6 -513
- package/.output/server/node_modules/unhead/package.json +5 -1
- package/.output/server/node_modules/unist-util-is/lib/index.js +10 -5
- package/.output/server/node_modules/unist-util-is/package.json +12 -9
- package/.output/server/node_modules/unist-util-visit-parents/lib/index.js +8 -7
- package/.output/server/node_modules/unist-util-visit-parents/package.json +18 -13
- package/.output/server/node_modules/yaml/dist/stringify/stringifyString.js +1 -1
- package/.output/server/node_modules/yaml/package.json +2 -1
- package/.output/server/package.json +27 -27
- package/bin/cli.js +23 -16
- package/bin/set-app-vue.js +3 -1
- package/bin/set-css.js +3 -1
- package/bin/set-eslint.js +3 -1
- package/bin/setup.js +10 -7
- package/nuxt.config.ts +13 -1
- package/package.json +15 -12
- package/test/versions.test.ts +65 -0
- package/vitest.config.ts +5 -5
- package/.nuxt/dist/server/client.manifest.json +0 -18
- package/.output/public/_nuxt/1soVlS0z.js +0 -1
- package/.output/public/_nuxt/B7rsWaa2.js +0 -1
- package/.output/public/_nuxt/BFreiu22.js +0 -1
- package/.output/public/_nuxt/BLcTglbc.js +0 -1
- package/.output/public/_nuxt/Bhd4_yFT.js +0 -1
- package/.output/public/_nuxt/Bhpb4lc3.js +0 -1
- package/.output/public/_nuxt/Bi2eMDmd.js +0 -1
- package/.output/public/_nuxt/Bm30MqE0.js +0 -1
- package/.output/public/_nuxt/BqsN2CZp.js +0 -1
- package/.output/public/_nuxt/Bs3IGOdt.js +0 -1
- package/.output/public/_nuxt/ByaiRTkI.js +0 -1
- package/.output/public/_nuxt/C9ePPGPX.js +0 -94
- package/.output/public/_nuxt/CA578xwz.js +0 -1
- package/.output/public/_nuxt/CDttUXKg.js +0 -1
- package/.output/public/_nuxt/CQozUI2A.js +0 -1
- package/.output/public/_nuxt/CSN71QT8.js +0 -1
- package/.output/public/_nuxt/CqCaqSd2.js +0 -1
- package/.output/public/_nuxt/D8v-efI7.js +0 -1
- package/.output/public/_nuxt/DBJqMhGy.js +0 -35
- package/.output/public/_nuxt/DR4hWRk7.js +0 -1
- package/.output/public/_nuxt/DRroQ-Xq.js +0 -1
- package/.output/public/_nuxt/DStnBfJS.js +0 -1
- package/.output/public/_nuxt/DXTYyv-V.js +0 -1
- package/.output/public/_nuxt/DeS1g0YT.js +0 -1
- package/.output/public/_nuxt/Deb6R53f.js +0 -1
- package/.output/public/_nuxt/DiDHllLr.js +0 -1
- package/.output/public/_nuxt/DvwlldUy.js +0 -1
- package/.output/public/_nuxt/DyCICqRh.js +0 -1
- package/.output/public/_nuxt/DzT4wm3Y.js +0 -1
- package/.output/public/_nuxt/E8nje24C.js +0 -1
- package/.output/public/_nuxt/RbPLLy5S.js +0 -1
- package/.output/public/_nuxt/builds/meta/cbc9377a-971e-4db1-b4b1-01807b82ee58.json +0 -1
- package/.output/public/_nuxt/entry.whtwWr_z.css +0 -1
- package/.output/public/_nuxt/error-404.Cq535Uij.css +0 -1
- package/.output/public/_nuxt/error-500.BHm_N15n.css +0 -1
- package/.output/public/_nuxt/jpnxxCHq.js +0 -1
- package/.output/public/_nuxt/sHsV3x2B.js +0 -1
- package/.output/public/_nuxt/sQEqbbg2.js +0 -1
- package/.output/public/_nuxt/vueform.ChEauysg.css +0 -1
- package/.output/server/chunks/build/client.manifest.mjs +0 -511
- package/.output/server/chunks/build/client.manifest.mjs.map +0 -1
|
@@ -1,358 +1,368 @@
|
|
|
1
1
|
import {isName} from '../util.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export default class DocTypeReader{
|
|
4
|
+
constructor(processEntities){
|
|
5
|
+
this.suppressValidationErr = !processEntities;
|
|
6
|
+
}
|
|
5
7
|
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
8
|
+
readDocType(xmlData, i){
|
|
9
|
+
|
|
10
|
+
const entities = {};
|
|
11
|
+
if( xmlData[i + 3] === 'O' &&
|
|
12
|
+
xmlData[i + 4] === 'C' &&
|
|
13
|
+
xmlData[i + 5] === 'T' &&
|
|
14
|
+
xmlData[i + 6] === 'Y' &&
|
|
15
|
+
xmlData[i + 7] === 'P' &&
|
|
16
|
+
xmlData[i + 8] === 'E')
|
|
17
|
+
{
|
|
18
|
+
i = i+9;
|
|
19
|
+
let angleBracketsCount = 1;
|
|
20
|
+
let hasBody = false, comment = false;
|
|
21
|
+
let exp = "";
|
|
22
|
+
for(;i<xmlData.length;i++){
|
|
23
|
+
if (xmlData[i] === '<' && !comment) { //Determine the tag type
|
|
24
|
+
if( hasBody && hasSeq(xmlData, "!ENTITY",i)){
|
|
25
|
+
i += 7;
|
|
26
|
+
let entityName, val;
|
|
27
|
+
[entityName, val,i] = this.readEntityExp(xmlData,i+1,this.suppressValidationErr);
|
|
28
|
+
if(val.indexOf("&") === -1) //Parameter entities are not supported
|
|
29
|
+
entities[ entityName ] = {
|
|
30
|
+
regx : RegExp( `&${entityName};`,"g"),
|
|
31
|
+
val: val
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else if( hasBody && hasSeq(xmlData, "!ELEMENT",i)) {
|
|
35
|
+
i += 8;//Not supported
|
|
36
|
+
const {index} = this.readElementExp(xmlData,i+1);
|
|
37
|
+
i = index;
|
|
38
|
+
}else if( hasBody && hasSeq(xmlData, "!ATTLIST",i)){
|
|
39
|
+
i += 8;//Not supported
|
|
40
|
+
// const {index} = this.readAttlistExp(xmlData,i+1);
|
|
41
|
+
// i = index;
|
|
42
|
+
}else if( hasBody && hasSeq(xmlData, "!NOTATION",i)) {
|
|
43
|
+
i += 9;//Not supported
|
|
44
|
+
const {index} = this.readNotationExp(xmlData,i+1,this.suppressValidationErr);
|
|
45
|
+
i = index;
|
|
46
|
+
}else if( hasSeq(xmlData, "!--",i) ) comment = true;
|
|
47
|
+
else throw new Error(`Invalid DOCTYPE`);
|
|
48
|
+
|
|
49
|
+
angleBracketsCount++;
|
|
50
|
+
exp = "";
|
|
51
|
+
} else if (xmlData[i] === '>') { //Read tag content
|
|
52
|
+
if(comment){
|
|
53
|
+
if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){
|
|
54
|
+
comment = false;
|
|
55
|
+
angleBracketsCount--;
|
|
56
|
+
}
|
|
57
|
+
}else{
|
|
51
58
|
angleBracketsCount--;
|
|
52
59
|
}
|
|
60
|
+
if (angleBracketsCount === 0) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}else if( xmlData[i] === '['){
|
|
64
|
+
hasBody = true;
|
|
53
65
|
}else{
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
if (angleBracketsCount === 0) {
|
|
57
|
-
break;
|
|
66
|
+
exp += xmlData[i];
|
|
58
67
|
}
|
|
59
|
-
}else if( xmlData[i] === '['){
|
|
60
|
-
hasBody = true;
|
|
61
|
-
}else{
|
|
62
|
-
exp += xmlData[i];
|
|
63
68
|
}
|
|
69
|
+
if(angleBracketsCount !== 0){
|
|
70
|
+
throw new Error(`Unclosed DOCTYPE`);
|
|
71
|
+
}
|
|
72
|
+
}else{
|
|
73
|
+
throw new Error(`Invalid Tag instead of DOCTYPE`);
|
|
64
74
|
}
|
|
65
|
-
|
|
66
|
-
throw new Error(`Unclosed DOCTYPE`);
|
|
67
|
-
}
|
|
68
|
-
}else{
|
|
69
|
-
throw new Error(`Invalid Tag instead of DOCTYPE`);
|
|
75
|
+
return {entities, i};
|
|
70
76
|
}
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
readEntityExp(xmlData, i) {
|
|
78
|
+
//External entities are not supported
|
|
79
|
+
// <!ENTITY ext SYSTEM "http://normal-website.com" >
|
|
73
80
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
index++;
|
|
77
|
-
}
|
|
78
|
-
return index;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
function readEntityExp(xmlData, i) {
|
|
82
|
-
//External entities are not supported
|
|
83
|
-
// <!ENTITY ext SYSTEM "http://normal-website.com" >
|
|
81
|
+
//Parameter entities are not supported
|
|
82
|
+
// <!ENTITY entityname "&anotherElement;">
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
//Internal entities are supported
|
|
85
|
+
// <!ENTITY entityname "replacement text">
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
// Skip leading whitespace after <!ENTITY
|
|
88
|
+
i = skipWhitespace(xmlData, i);
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
// Read entity name
|
|
91
|
+
let entityName = "";
|
|
92
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
|
|
93
|
+
entityName += xmlData[i];
|
|
94
|
+
i++;
|
|
95
|
+
}
|
|
96
|
+
validateEntityName(entityName);
|
|
93
97
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
|
|
97
|
-
entityName += xmlData[i];
|
|
98
|
-
i++;
|
|
99
|
-
}
|
|
100
|
-
validateEntityName(entityName);
|
|
98
|
+
// Skip whitespace after entity name
|
|
99
|
+
i = skipWhitespace(xmlData, i);
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
// Check for unsupported constructs (external entities or parameter entities)
|
|
102
|
+
if(!this.suppressValidationErr){
|
|
103
|
+
if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
|
|
104
|
+
throw new Error("External entities are not supported");
|
|
105
|
+
}else if (xmlData[i] === "%") {
|
|
106
|
+
throw new Error("Parameter entities are not supported");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
104
109
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
// Read entity value (internal entity)
|
|
111
|
+
let entityValue = "";
|
|
112
|
+
[i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
|
|
113
|
+
i--;
|
|
114
|
+
return [entityName, entityValue, i ];
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
i--;
|
|
116
|
-
return [entityName, entityValue, i ];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function readNotationExp(xmlData, i) {
|
|
120
|
-
// Skip leading whitespace after <!NOTATION
|
|
121
|
-
i = skipWhitespace(xmlData, i);
|
|
117
|
+
readNotationExp(xmlData, i) {
|
|
118
|
+
// Skip leading whitespace after <!NOTATION
|
|
119
|
+
i = skipWhitespace(xmlData, i);
|
|
122
120
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
// Read notation name
|
|
122
|
+
let notationName = "";
|
|
123
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
124
|
+
notationName += xmlData[i];
|
|
125
|
+
i++;
|
|
126
|
+
}
|
|
127
|
+
!this.suppressValidationErr && validateEntityName(notationName);
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
// Skip whitespace after notation name
|
|
130
|
+
i = skipWhitespace(xmlData, i);
|
|
133
131
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
// Check identifier type (SYSTEM or PUBLIC)
|
|
133
|
+
const identifierType = xmlData.substring(i, i + 6).toUpperCase();
|
|
134
|
+
if (!this.suppressValidationErr && identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
|
|
135
|
+
throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
|
|
136
|
+
}
|
|
137
|
+
i += identifierType.length;
|
|
140
138
|
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
// Skip whitespace after identifier type
|
|
140
|
+
i = skipWhitespace(xmlData, i);
|
|
143
141
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
// Read public identifier (if PUBLIC)
|
|
143
|
+
let publicIdentifier = null;
|
|
144
|
+
let systemIdentifier = null;
|
|
147
145
|
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
if (identifierType === "PUBLIC") {
|
|
147
|
+
[i, publicIdentifier ] = this.readIdentifierVal(xmlData, i, "publicIdentifier");
|
|
150
148
|
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
// Skip whitespace after public identifier
|
|
150
|
+
i = skipWhitespace(xmlData, i);
|
|
153
151
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
// Optionally read system identifier
|
|
153
|
+
if (xmlData[i] === '"' || xmlData[i] === "'") {
|
|
154
|
+
[i, systemIdentifier ] = this.readIdentifierVal(xmlData, i,"systemIdentifier");
|
|
155
|
+
}
|
|
156
|
+
} else if (identifierType === "SYSTEM") {
|
|
157
|
+
// Read system identifier (mandatory for SYSTEM)
|
|
158
|
+
[i, systemIdentifier ] = this.readIdentifierVal(xmlData, i, "systemIdentifier");
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
if (!this.suppressValidationErr && !systemIdentifier) {
|
|
161
|
+
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
|
162
|
+
}
|
|
164
163
|
}
|
|
164
|
+
|
|
165
|
+
return {notationName, publicIdentifier, systemIdentifier, index: --i};
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
-
return {notationName, publicIdentifier, systemIdentifier, index: --i};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function readIdentifierVal(xmlData, i, type) {
|
|
171
|
-
let identifierVal = "";
|
|
172
|
-
const startChar = xmlData[i];
|
|
173
|
-
if (startChar !== '"' && startChar !== "'") {
|
|
174
|
-
throw new Error(`Expected quoted string, found "${startChar}"`);
|
|
175
|
-
}
|
|
176
|
-
i++;
|
|
177
167
|
|
|
178
|
-
|
|
179
|
-
identifierVal
|
|
168
|
+
readIdentifierVal(xmlData, i, type) {
|
|
169
|
+
let identifierVal = "";
|
|
170
|
+
const startChar = xmlData[i];
|
|
171
|
+
if (startChar !== '"' && startChar !== "'") {
|
|
172
|
+
throw new Error(`Expected quoted string, found "${startChar}"`);
|
|
173
|
+
}
|
|
180
174
|
i++;
|
|
181
|
-
}
|
|
182
175
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return [i, identifierVal];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function readElementExp(xmlData, i) {
|
|
191
|
-
// <!ELEMENT br EMPTY>
|
|
192
|
-
// <!ELEMENT div ANY>
|
|
193
|
-
// <!ELEMENT title (#PCDATA)>
|
|
194
|
-
// <!ELEMENT book (title, author+)>
|
|
195
|
-
// <!ELEMENT name (content-model)>
|
|
196
|
-
|
|
197
|
-
// Skip leading whitespace after <!ELEMENT
|
|
198
|
-
i = skipWhitespace(xmlData, i);
|
|
176
|
+
while (i < xmlData.length && xmlData[i] !== startChar) {
|
|
177
|
+
identifierVal += xmlData[i];
|
|
178
|
+
i++;
|
|
179
|
+
}
|
|
199
180
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
elementName += xmlData[i];
|
|
181
|
+
if (xmlData[i] !== startChar) {
|
|
182
|
+
throw new Error(`Unterminated ${type} value`);
|
|
183
|
+
}
|
|
204
184
|
i++;
|
|
185
|
+
return [i, identifierVal];
|
|
205
186
|
}
|
|
206
187
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
188
|
+
readElementExp(xmlData, i) {
|
|
189
|
+
// <!ELEMENT br EMPTY>
|
|
190
|
+
// <!ELEMENT div ANY>
|
|
191
|
+
// <!ELEMENT title (#PCDATA)>
|
|
192
|
+
// <!ELEMENT book (title, author+)>
|
|
193
|
+
// <!ELEMENT name (content-model)>
|
|
194
|
+
|
|
195
|
+
// Skip leading whitespace after <!ELEMENT
|
|
196
|
+
i = skipWhitespace(xmlData, i);
|
|
211
197
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if(xmlData[i] === "E" && hasSeq(xmlData, "MPTY",i)) i+=4;
|
|
217
|
-
else if(xmlData[i] === "A" && hasSeq(xmlData, "NY",i)) i+=2;
|
|
218
|
-
else if (xmlData[i] === "(") {
|
|
219
|
-
i++; // Move past '('
|
|
220
|
-
|
|
221
|
-
// Read content model
|
|
222
|
-
while (i < xmlData.length && xmlData[i] !== ")") {
|
|
223
|
-
contentModel += xmlData[i];
|
|
198
|
+
// Read element name
|
|
199
|
+
let elementName = "";
|
|
200
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
201
|
+
elementName += xmlData[i];
|
|
224
202
|
i++;
|
|
225
203
|
}
|
|
226
|
-
if (xmlData[i] !== ")") {
|
|
227
|
-
throw new Error("Unterminated content model");
|
|
228
|
-
}
|
|
229
204
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return {
|
|
235
|
-
elementName,
|
|
236
|
-
contentModel: contentModel.trim(),
|
|
237
|
-
index: i
|
|
238
|
-
};
|
|
239
|
-
}
|
|
205
|
+
// Validate element name
|
|
206
|
+
if (!this.suppressValidationErr && !isName(elementName)) {
|
|
207
|
+
throw new Error(`Invalid element name: "${elementName}"`);
|
|
208
|
+
}
|
|
240
209
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
210
|
+
// Skip whitespace after element name
|
|
211
|
+
i = skipWhitespace(xmlData, i);
|
|
212
|
+
let contentModel = "";
|
|
213
|
+
// Expect '(' to start content model
|
|
214
|
+
if(xmlData[i] === "E" && hasSeq(xmlData, "MPTY",i)) i+=4;
|
|
215
|
+
else if(xmlData[i] === "A" && hasSeq(xmlData, "NY",i)) i+=2;
|
|
216
|
+
else if (xmlData[i] === "(") {
|
|
217
|
+
i++; // Move past '('
|
|
218
|
+
|
|
219
|
+
// Read content model
|
|
220
|
+
while (i < xmlData.length && xmlData[i] !== ")") {
|
|
221
|
+
contentModel += xmlData[i];
|
|
222
|
+
i++;
|
|
223
|
+
}
|
|
224
|
+
if (xmlData[i] !== ")") {
|
|
225
|
+
throw new Error("Unterminated content model");
|
|
226
|
+
}
|
|
244
227
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
228
|
+
}else if(!this.suppressValidationErr){
|
|
229
|
+
throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
elementName,
|
|
234
|
+
contentModel: contentModel.trim(),
|
|
235
|
+
index: i
|
|
236
|
+
};
|
|
250
237
|
}
|
|
251
238
|
|
|
252
|
-
|
|
253
|
-
|
|
239
|
+
readAttlistExp(xmlData, i) {
|
|
240
|
+
// Skip leading whitespace after <!ATTLIST
|
|
241
|
+
i = skipWhitespace(xmlData, i);
|
|
254
242
|
|
|
255
|
-
|
|
256
|
-
|
|
243
|
+
// Read element name
|
|
244
|
+
let elementName = "";
|
|
245
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
246
|
+
elementName += xmlData[i];
|
|
247
|
+
i++;
|
|
248
|
+
}
|
|
257
249
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
261
|
-
attributeName += xmlData[i];
|
|
262
|
-
i++;
|
|
263
|
-
}
|
|
250
|
+
// Validate element name
|
|
251
|
+
validateEntityName(elementName)
|
|
264
252
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
throw new Error(`Invalid attribute name: "${attributeName}"`);
|
|
268
|
-
}
|
|
253
|
+
// Skip whitespace after element name
|
|
254
|
+
i = skipWhitespace(xmlData, i);
|
|
269
255
|
|
|
270
|
-
|
|
271
|
-
|
|
256
|
+
// Read attribute name
|
|
257
|
+
let attributeName = "";
|
|
258
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
259
|
+
attributeName += xmlData[i];
|
|
260
|
+
i++;
|
|
261
|
+
}
|
|
272
262
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
i += 8; // Move past "NOTATION"
|
|
263
|
+
// Validate attribute name
|
|
264
|
+
if (!validateEntityName(attributeName)) {
|
|
265
|
+
throw new Error(`Invalid attribute name: "${attributeName}"`);
|
|
266
|
+
}
|
|
278
267
|
|
|
279
|
-
// Skip whitespace after
|
|
268
|
+
// Skip whitespace after attribute name
|
|
280
269
|
i = skipWhitespace(xmlData, i);
|
|
281
270
|
|
|
282
|
-
//
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
i++;
|
|
271
|
+
// Read attribute type
|
|
272
|
+
let attributeType = "";
|
|
273
|
+
if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
|
|
274
|
+
attributeType = "NOTATION";
|
|
275
|
+
i += 8; // Move past "NOTATION"
|
|
276
|
+
|
|
277
|
+
// Skip whitespace after "NOTATION"
|
|
278
|
+
i = skipWhitespace(xmlData, i);
|
|
279
|
+
|
|
280
|
+
// Expect '(' to start the list of notations
|
|
281
|
+
if (xmlData[i] !== "(") {
|
|
282
|
+
throw new Error(`Expected '(', found "${xmlData[i]}"`);
|
|
295
283
|
}
|
|
284
|
+
i++; // Move past '('
|
|
285
|
+
|
|
286
|
+
// Read the list of allowed notations
|
|
287
|
+
let allowedNotations = [];
|
|
288
|
+
while (i < xmlData.length && xmlData[i] !== ")") {
|
|
289
|
+
let notation = "";
|
|
290
|
+
while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
|
|
291
|
+
notation += xmlData[i];
|
|
292
|
+
i++;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Validate notation name
|
|
296
|
+
notation = notation.trim();
|
|
297
|
+
if (!validateEntityName(notation)) {
|
|
298
|
+
throw new Error(`Invalid notation name: "${notation}"`);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
allowedNotations.push(notation);
|
|
296
302
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
303
|
+
// Skip '|' separator or exit loop
|
|
304
|
+
if (xmlData[i] === "|") {
|
|
305
|
+
i++; // Move past '|'
|
|
306
|
+
i = skipWhitespace(xmlData, i); // Skip optional whitespace after '|'
|
|
307
|
+
}
|
|
301
308
|
}
|
|
302
309
|
|
|
303
|
-
|
|
310
|
+
if (xmlData[i] !== ")") {
|
|
311
|
+
throw new Error("Unterminated list of notations");
|
|
312
|
+
}
|
|
313
|
+
i++; // Move past ')'
|
|
314
|
+
|
|
315
|
+
// Store the allowed notations as part of the attribute type
|
|
316
|
+
attributeType += " (" + allowedNotations.join("|") + ")";
|
|
317
|
+
} else {
|
|
318
|
+
// Handle simple types (e.g., CDATA, ID, IDREF, etc.)
|
|
319
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
320
|
+
attributeType += xmlData[i];
|
|
321
|
+
i++;
|
|
322
|
+
}
|
|
304
323
|
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
324
|
+
// Validate simple attribute type
|
|
325
|
+
const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
|
|
326
|
+
if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
|
|
327
|
+
throw new Error(`Invalid attribute type: "${attributeType}"`);
|
|
309
328
|
}
|
|
310
329
|
}
|
|
311
330
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
i++; // Move past ')'
|
|
331
|
+
// Skip whitespace after attribute type
|
|
332
|
+
i = skipWhitespace(xmlData, i);
|
|
316
333
|
|
|
317
|
-
//
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
334
|
+
// Read default value
|
|
335
|
+
let defaultValue = "";
|
|
336
|
+
if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
|
|
337
|
+
defaultValue = "#REQUIRED";
|
|
338
|
+
i += 8;
|
|
339
|
+
} else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
|
|
340
|
+
defaultValue = "#IMPLIED";
|
|
341
|
+
i += 7;
|
|
342
|
+
} else {
|
|
343
|
+
[i, defaultValue] = this.readIdentifierVal(xmlData, i, "ATTLIST");
|
|
324
344
|
}
|
|
325
345
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
346
|
+
return {
|
|
347
|
+
elementName,
|
|
348
|
+
attributeName,
|
|
349
|
+
attributeType,
|
|
350
|
+
defaultValue,
|
|
351
|
+
index: i
|
|
330
352
|
}
|
|
331
353
|
}
|
|
354
|
+
}
|
|
332
355
|
|
|
333
|
-
// Skip whitespace after attribute type
|
|
334
|
-
i = skipWhitespace(xmlData, i);
|
|
335
|
-
|
|
336
|
-
// Read default value
|
|
337
|
-
let defaultValue = "";
|
|
338
|
-
if (xmlData.substring(i, i + 8).toUpperCase() === "#REQUIRED") {
|
|
339
|
-
defaultValue = "#REQUIRED";
|
|
340
|
-
i += 8;
|
|
341
|
-
} else if (xmlData.substring(i, i + 7).toUpperCase() === "#IMPLIED") {
|
|
342
|
-
defaultValue = "#IMPLIED";
|
|
343
|
-
i += 7;
|
|
344
|
-
} else {
|
|
345
|
-
[i, defaultValue] = readIdentifierVal(xmlData, i, "ATTLIST");
|
|
346
|
-
}
|
|
347
356
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
defaultValue,
|
|
353
|
-
index: i
|
|
357
|
+
|
|
358
|
+
const skipWhitespace = (data, index) => {
|
|
359
|
+
while (index < data.length && /\s/.test(data[index])) {
|
|
360
|
+
index++;
|
|
354
361
|
}
|
|
355
|
-
|
|
362
|
+
return index;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
|
|
356
366
|
|
|
357
367
|
function hasSeq(data, seq,i){
|
|
358
368
|
for(let j=0;j<seq.length;j++){
|
|
@@ -363,7 +373,7 @@ function hasSeq(data, seq,i){
|
|
|
363
373
|
|
|
364
374
|
function validateEntityName(name){
|
|
365
375
|
if (isName(name))
|
|
366
|
-
|
|
376
|
+
return name;
|
|
367
377
|
else
|
|
368
378
|
throw new Error(`Invalid entity name ${name}`);
|
|
369
379
|
}
|