@cdk8s/awscdk-resolver 0.0.318 → 0.0.319
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/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +14 -14
- package/node_modules/@aws-sdk/client-sso/package.json +13 -13
- package/node_modules/@aws-sdk/core/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +4 -4
- package/node_modules/@aws-sdk/nested-clients/package.json +13 -13
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js +30 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-es/index.js +1 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-es/resolveDefaultAwsRegionalEndpointsConfig.js +21 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-types/index.d.ts +1 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-types/resolveDefaultAwsRegionalEndpointsConfig.d.ts +56 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-types/ts3.4/index.d.ts +1 -0
- package/node_modules/@aws-sdk/util-endpoints/dist-types/ts3.4/resolveDefaultAwsRegionalEndpointsConfig.d.ts +35 -0
- package/node_modules/@aws-sdk/util-endpoints/package.json +2 -1
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +20 -20
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +80 -6
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +20 -20
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +10 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ListSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/MapSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/StructureSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +3 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +3 -0
- package/node_modules/@smithy/core/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -2
- package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +4 -4
- package/node_modules/@smithy/fetch-http-handler/dist-types/fetch-http-handler.d.ts +1 -1
- package/node_modules/@smithy/fetch-http-handler/dist-types/ts3.4/fetch-http-handler.d.ts +1 -1
- package/node_modules/@smithy/fetch-http-handler/package.json +1 -1
- package/node_modules/@smithy/middleware-endpoint/dist-cjs/index.js +5 -2
- package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/createConfigValueProvider.js +3 -0
- package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/getEndpointFromInstructions.js +1 -1
- package/node_modules/@smithy/middleware-endpoint/dist-es/endpointMiddleware.js +1 -1
- package/node_modules/@smithy/middleware-endpoint/dist-types/resolveEndpointConfig.d.ts +5 -2
- package/node_modules/@smithy/middleware-endpoint/dist-types/ts3.4/resolveEndpointConfig.d.ts +5 -2
- package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
- package/node_modules/@smithy/middleware-retry/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +11 -9
- package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +4 -3
- package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +7 -6
- package/node_modules/@smithy/node-http-handler/dist-types/node-http-handler.d.ts +1 -1
- package/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +1 -1
- package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http-handler.d.ts +1 -1
- package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +1 -1
- package/node_modules/@smithy/node-http-handler/package.json +1 -1
- package/node_modules/@smithy/smithy-client/package.json +4 -4
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/node_modules/@smithy/util-stream/package.json +3 -3
- package/node_modules/fast-xml-parser/CHANGELOG.md +77 -0
- package/node_modules/fast-xml-parser/README.md +39 -52
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
- package/node_modules/fast-xml-parser/lib/fxp.d.cts +458 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +2 -0
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
- package/node_modules/fast-xml-parser/package.json +36 -20
- package/node_modules/fast-xml-parser/src/cli/cli.js +16 -12
- package/node_modules/fast-xml-parser/src/cli/man.js +6 -1
- package/node_modules/fast-xml-parser/src/cli/read.js +30 -79
- package/node_modules/fast-xml-parser/src/fxp.d.ts +52 -9
- package/node_modules/fast-xml-parser/src/fxp.js +11 -8
- package/node_modules/fast-xml-parser/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-parser/src/util.js +14 -18
- package/node_modules/fast-xml-parser/src/{v5 → v6}/CharsSymbol.js +1 -1
- package/node_modules/fast-xml-parser/src/{v5/valueParsers → v6}/EntitiesParser.js +3 -6
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OptionsBuilder.js +3 -6
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/BaseOutputBuilder.js +1 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsArrBuilder.js +3 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsMinArrBuilder.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/JsObjBuilder.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/OutputBuilders/ParserOptionsBuilder.js +6 -11
- package/node_modules/fast-xml-parser/src/{v5 → v6}/TagPath.js +1 -1
- package/node_modules/fast-xml-parser/src/{v5 → v6}/TagPathMatcher.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/XMLParser.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/Xml2JsParser.js +8 -10
- package/node_modules/fast-xml-parser/src/{v5 → v6}/XmlPartReader.js +24 -26
- package/node_modules/fast-xml-parser/src/{v5 → v6}/XmlSpecialTagsReader.js +5 -12
- package/node_modules/fast-xml-parser/src/{v5 → v6}/inputSource/BufferSource.js +1 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6}/inputSource/StringSource.js +1 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6/valueParsers}/EntitiesParser.js +3 -5
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/booleanParser.js +1 -2
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/booleanParserExt.js +1 -2
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/currency.js +1 -3
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/join.js +1 -2
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/number.js +2 -4
- package/node_modules/fast-xml-parser/src/{v5 → v6}/valueParsers/trim.js +1 -3
- package/node_modules/fast-xml-parser/src/validator.js +5 -5
- package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +17 -13
- package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +1 -2
- package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +288 -71
- package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +3 -5
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +28 -23
- package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +21 -8
- package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +8 -2
- package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +22 -7
- package/node_modules/strnum/.github/SECURITY.md +5 -0
- package/node_modules/strnum/CHANGELOG.md +11 -0
- package/node_modules/strnum/algo.stflow +84 -0
- package/node_modules/strnum/package.json +2 -1
- package/node_modules/strnum/strnum.js +53 -35
- package/node_modules/strnum/strnum.test.js +9 -1
- package/node_modules/strnum/test.js +9 -0
- package/package.json +4 -4
- /package/node_modules/fast-xml-parser/src/{v5 → v6}/Report.js +0 -0
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
import {isName} from '../util.js';
|
2
2
|
|
3
3
|
//TODO: handle comments
|
4
|
-
function readDocType(xmlData, i){
|
4
|
+
export default function readDocType(xmlData, i){
|
5
5
|
|
6
6
|
const entities = {};
|
7
7
|
if( xmlData[i + 3] === 'O' &&
|
@@ -17,20 +17,30 @@ function readDocType(xmlData, i){
|
|
17
17
|
let exp = "";
|
18
18
|
for(;i<xmlData.length;i++){
|
19
19
|
if (xmlData[i] === '<' && !comment) { //Determine the tag type
|
20
|
-
if( hasBody &&
|
20
|
+
if( hasBody && hasSeq(xmlData, "!ENTITY",i)){
|
21
21
|
i += 7;
|
22
|
+
let entityName, val;
|
22
23
|
[entityName, val,i] = readEntityExp(xmlData,i+1);
|
23
24
|
if(val.indexOf("&") === -1) //Parameter entities are not supported
|
24
|
-
entities[
|
25
|
+
entities[ entityName ] = {
|
25
26
|
regx : RegExp( `&${entityName};`,"g"),
|
26
27
|
val: val
|
27
28
|
};
|
28
29
|
}
|
29
|
-
else if( hasBody &&
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
else
|
30
|
+
else if( hasBody && hasSeq(xmlData, "!ELEMENT",i)) {
|
31
|
+
i += 8;//Not supported
|
32
|
+
const {index} = readElementExp(xmlData,i+1);
|
33
|
+
i = index;
|
34
|
+
}else if( hasBody && hasSeq(xmlData, "!ATTLIST",i)){
|
35
|
+
i += 8;//Not supported
|
36
|
+
// const {index} = readAttlistExp(xmlData,i+1);
|
37
|
+
// i = index;
|
38
|
+
}else if( hasBody && hasSeq(xmlData, "!NOTATION",i)) {
|
39
|
+
i += 9;//Not supported
|
40
|
+
const {index} = readNotationExp(xmlData,i+1);
|
41
|
+
i = index;
|
42
|
+
}else if( hasSeq(xmlData, "!--",i) ) comment = true;
|
43
|
+
else throw new Error(`Invalid DOCTYPE`);
|
34
44
|
|
35
45
|
angleBracketsCount++;
|
36
46
|
exp = "";
|
@@ -61,7 +71,14 @@ function readDocType(xmlData, i){
|
|
61
71
|
return {entities, i};
|
62
72
|
}
|
63
73
|
|
64
|
-
|
74
|
+
const skipWhitespace = (data, index) => {
|
75
|
+
while (index < data.length && /\s/.test(data[index])) {
|
76
|
+
index++;
|
77
|
+
}
|
78
|
+
return index;
|
79
|
+
};
|
80
|
+
|
81
|
+
function readEntityExp(xmlData, i) {
|
65
82
|
//External entities are not supported
|
66
83
|
// <!ENTITY ext SYSTEM "http://normal-website.com" >
|
67
84
|
|
@@ -70,83 +87,283 @@ function readEntityExp(xmlData,i){
|
|
70
87
|
|
71
88
|
//Internal entities are supported
|
72
89
|
// <!ENTITY entityname "replacement text">
|
73
|
-
|
74
|
-
//
|
90
|
+
|
91
|
+
// Skip leading whitespace after <!ENTITY
|
92
|
+
i = skipWhitespace(xmlData, i);
|
93
|
+
|
94
|
+
// Read entity name
|
75
95
|
let entityName = "";
|
76
|
-
|
77
|
-
// if(xmlData[i] === " ") continue;
|
78
|
-
// else
|
96
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
|
79
97
|
entityName += xmlData[i];
|
98
|
+
i++;
|
80
99
|
}
|
81
|
-
entityName
|
82
|
-
if(entityName.indexOf(" ") !== -1) throw new Error("External entites are not supported");
|
100
|
+
validateEntityName(entityName);
|
83
101
|
|
84
|
-
//
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
102
|
+
// Skip whitespace after entity name
|
103
|
+
i = skipWhitespace(xmlData, i);
|
104
|
+
|
105
|
+
// Check for unsupported constructs (external entities or parameter entities)
|
106
|
+
if (xmlData.substring(i, i + 6).toUpperCase() === "SYSTEM") {
|
107
|
+
throw new Error("External entities are not supported");
|
108
|
+
}else if (xmlData[i] === "%") {
|
109
|
+
throw new Error("Parameter entities are not supported");
|
89
110
|
}
|
90
|
-
|
111
|
+
|
112
|
+
// Read entity value (internal entity)
|
113
|
+
let entityValue = "";
|
114
|
+
[i, entityValue] = readIdentifierVal(xmlData, i, "entity");
|
115
|
+
i--;
|
116
|
+
return [entityName, entityValue, i ];
|
91
117
|
}
|
92
118
|
|
93
|
-
function
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
119
|
+
function readNotationExp(xmlData, i) {
|
120
|
+
// Skip leading whitespace after <!NOTATION
|
121
|
+
i = skipWhitespace(xmlData, i);
|
122
|
+
|
123
|
+
// Read notation name
|
124
|
+
let notationName = "";
|
125
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
126
|
+
notationName += xmlData[i];
|
127
|
+
i++;
|
128
|
+
}
|
129
|
+
validateEntityName(notationName);
|
130
|
+
|
131
|
+
// Skip whitespace after notation name
|
132
|
+
i = skipWhitespace(xmlData, i);
|
133
|
+
|
134
|
+
// Check identifier type (SYSTEM or PUBLIC)
|
135
|
+
const identifierType = xmlData.substring(i, i + 6).toUpperCase();
|
136
|
+
if (identifierType !== "SYSTEM" && identifierType !== "PUBLIC") {
|
137
|
+
throw new Error(`Expected SYSTEM or PUBLIC, found "${identifierType}"`);
|
138
|
+
}
|
139
|
+
i += identifierType.length;
|
140
|
+
|
141
|
+
// Skip whitespace after identifier type
|
142
|
+
i = skipWhitespace(xmlData, i);
|
143
|
+
|
144
|
+
// Read public identifier (if PUBLIC)
|
145
|
+
let publicIdentifier = null;
|
146
|
+
let systemIdentifier = null;
|
147
|
+
|
148
|
+
if (identifierType === "PUBLIC") {
|
149
|
+
[i, publicIdentifier ] = readIdentifierVal(xmlData, i, "publicIdentifier");
|
150
|
+
|
151
|
+
// Skip whitespace after public identifier
|
152
|
+
i = skipWhitespace(xmlData, i);
|
153
|
+
|
154
|
+
// Optionally read system identifier
|
155
|
+
if (xmlData[i] === '"' || xmlData[i] === "'") {
|
156
|
+
[i, systemIdentifier ] = readIdentifierVal(xmlData, i,"systemIdentifier");
|
157
|
+
}
|
158
|
+
} else if (identifierType === "SYSTEM") {
|
159
|
+
// Read system identifier (mandatory for SYSTEM)
|
160
|
+
[i, systemIdentifier ] = readIdentifierVal(xmlData, i, "systemIdentifier");
|
161
|
+
|
162
|
+
if (!systemIdentifier) {
|
163
|
+
throw new Error("Missing mandatory system identifier for SYSTEM notation");
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
return {notationName, publicIdentifier, systemIdentifier, index: --i};
|
98
168
|
}
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
xmlData[i
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
+
|
178
|
+
while (i < xmlData.length && xmlData[i] !== startChar) {
|
179
|
+
identifierVal += xmlData[i];
|
180
|
+
i++;
|
181
|
+
}
|
182
|
+
|
183
|
+
if (xmlData[i] !== startChar) {
|
184
|
+
throw new Error(`Unterminated ${type} value`);
|
185
|
+
}
|
186
|
+
i++;
|
187
|
+
return [i, identifierVal];
|
108
188
|
}
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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);
|
199
|
+
|
200
|
+
// Read element name
|
201
|
+
let elementName = "";
|
202
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
203
|
+
elementName += xmlData[i];
|
204
|
+
i++;
|
205
|
+
}
|
206
|
+
|
207
|
+
// Validate element name
|
208
|
+
if (!validateEntityName(elementName)) {
|
209
|
+
throw new Error(`Invalid element name: "${elementName}"`);
|
210
|
+
}
|
211
|
+
|
212
|
+
// Skip whitespace after element name
|
213
|
+
i = skipWhitespace(xmlData, i);
|
214
|
+
let contentModel = "";
|
215
|
+
// Expect '(' to start content model
|
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];
|
224
|
+
i++;
|
225
|
+
}
|
226
|
+
if (xmlData[i] !== ")") {
|
227
|
+
throw new Error("Unterminated content model");
|
228
|
+
}
|
229
|
+
|
230
|
+
}else{
|
231
|
+
throw new Error(`Invalid Element Expression, found "${xmlData[i]}"`);
|
232
|
+
}
|
233
|
+
|
234
|
+
return {
|
235
|
+
elementName,
|
236
|
+
contentModel: contentModel.trim(),
|
237
|
+
index: i
|
238
|
+
};
|
119
239
|
}
|
120
240
|
|
121
|
-
function
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
xmlData[i
|
128
|
-
|
129
|
-
|
130
|
-
|
241
|
+
function readAttlistExp(xmlData, i) {
|
242
|
+
// Skip leading whitespace after <!ATTLIST
|
243
|
+
i = skipWhitespace(xmlData, i);
|
244
|
+
|
245
|
+
// Read element name
|
246
|
+
let elementName = "";
|
247
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
248
|
+
elementName += xmlData[i];
|
249
|
+
i++;
|
250
|
+
}
|
251
|
+
|
252
|
+
// Validate element name
|
253
|
+
validateEntityName(elementName)
|
254
|
+
|
255
|
+
// Skip whitespace after element name
|
256
|
+
i = skipWhitespace(xmlData, i);
|
257
|
+
|
258
|
+
// Read attribute name
|
259
|
+
let attributeName = "";
|
260
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
261
|
+
attributeName += xmlData[i];
|
262
|
+
i++;
|
263
|
+
}
|
264
|
+
|
265
|
+
// Validate attribute name
|
266
|
+
if (!validateEntityName(attributeName)) {
|
267
|
+
throw new Error(`Invalid attribute name: "${attributeName}"`);
|
268
|
+
}
|
269
|
+
|
270
|
+
// Skip whitespace after attribute name
|
271
|
+
i = skipWhitespace(xmlData, i);
|
272
|
+
|
273
|
+
// Read attribute type
|
274
|
+
let attributeType = "";
|
275
|
+
if (xmlData.substring(i, i + 8).toUpperCase() === "NOTATION") {
|
276
|
+
attributeType = "NOTATION";
|
277
|
+
i += 8; // Move past "NOTATION"
|
278
|
+
|
279
|
+
// Skip whitespace after "NOTATION"
|
280
|
+
i = skipWhitespace(xmlData, i);
|
281
|
+
|
282
|
+
// Expect '(' to start the list of notations
|
283
|
+
if (xmlData[i] !== "(") {
|
284
|
+
throw new Error(`Expected '(', found "${xmlData[i]}"`);
|
285
|
+
}
|
286
|
+
i++; // Move past '('
|
287
|
+
|
288
|
+
// Read the list of allowed notations
|
289
|
+
let allowedNotations = [];
|
290
|
+
while (i < xmlData.length && xmlData[i] !== ")") {
|
291
|
+
let notation = "";
|
292
|
+
while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
|
293
|
+
notation += xmlData[i];
|
294
|
+
i++;
|
295
|
+
}
|
296
|
+
|
297
|
+
// Validate notation name
|
298
|
+
notation = notation.trim();
|
299
|
+
if (!validateEntityName(notation)) {
|
300
|
+
throw new Error(`Invalid notation name: "${notation}"`);
|
301
|
+
}
|
302
|
+
|
303
|
+
allowedNotations.push(notation);
|
304
|
+
|
305
|
+
// Skip '|' separator or exit loop
|
306
|
+
if (xmlData[i] === "|") {
|
307
|
+
i++; // Move past '|'
|
308
|
+
i = skipWhitespace(xmlData, i); // Skip optional whitespace after '|'
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
if (xmlData[i] !== ")") {
|
313
|
+
throw new Error("Unterminated list of notations");
|
314
|
+
}
|
315
|
+
i++; // Move past ')'
|
316
|
+
|
317
|
+
// Store the allowed notations as part of the attribute type
|
318
|
+
attributeType += " (" + allowedNotations.join("|") + ")";
|
319
|
+
} else {
|
320
|
+
// Handle simple types (e.g., CDATA, ID, IDREF, etc.)
|
321
|
+
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
322
|
+
attributeType += xmlData[i];
|
323
|
+
i++;
|
324
|
+
}
|
325
|
+
|
326
|
+
// Validate simple attribute type
|
327
|
+
const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
|
328
|
+
if (!validTypes.includes(attributeType.toUpperCase())) {
|
329
|
+
throw new Error(`Invalid attribute type: "${attributeType}"`);
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
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
|
+
|
348
|
+
return {
|
349
|
+
elementName,
|
350
|
+
attributeName,
|
351
|
+
attributeType,
|
352
|
+
defaultValue,
|
353
|
+
index: i
|
354
|
+
}
|
131
355
|
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
xmlData[i+6] === 'T' &&
|
139
|
-
xmlData[i+7] === 'I' &&
|
140
|
-
xmlData[i+8] === 'O' &&
|
141
|
-
xmlData[i+9] === 'N') return true
|
142
|
-
return false
|
356
|
+
|
357
|
+
function hasSeq(data, seq,i){
|
358
|
+
for(let j=0;j<seq.length;j++){
|
359
|
+
if(seq[j]!==data[i+j+1]) return false;
|
360
|
+
}
|
361
|
+
return true;
|
143
362
|
}
|
144
363
|
|
145
364
|
function validateEntityName(name){
|
146
|
-
if (
|
365
|
+
if (isName(name))
|
147
366
|
return name;
|
148
367
|
else
|
149
368
|
throw new Error(`Invalid entity name ${name}`);
|
150
369
|
}
|
151
|
-
|
152
|
-
module.exports = readDocType;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
const defaultOptions = {
|
2
|
+
export const defaultOptions = {
|
3
3
|
preserveOrder: false,
|
4
4
|
attributeNamePrefix: '@_',
|
5
5
|
attributesGroupName: false,
|
@@ -38,11 +38,9 @@ const defaultOptions = {
|
|
38
38
|
return tagName
|
39
39
|
},
|
40
40
|
// skipEmptyListItem: false
|
41
|
+
captureMetaData: false,
|
41
42
|
};
|
42
43
|
|
43
|
-
const buildOptions = function(options) {
|
44
|
+
export const buildOptions = function(options) {
|
44
45
|
return Object.assign({}, defaultOptions, options);
|
45
46
|
};
|
46
|
-
|
47
|
-
exports.buildOptions = buildOptions;
|
48
|
-
exports.defaultOptions = defaultOptions;
|
@@ -1,10 +1,11 @@
|
|
1
1
|
'use strict';
|
2
2
|
///@ts-check
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
import {getAllMatches, isExist} from '../util.js';
|
5
|
+
import xmlNode from './xmlNode.js';
|
6
|
+
import readDocType from './DocTypeReader.js';
|
7
|
+
import toNumber from "strnum";
|
8
|
+
import getIgnoreAttributesFn from "../ignoreAttributes.js";
|
8
9
|
|
9
10
|
// const regx =
|
10
11
|
// '<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)'
|
@@ -13,7 +14,7 @@ const toNumber = require("strnum");
|
|
13
14
|
//const tagsRegx = new RegExp("<(\\/?[\\w:\\-\._]+)([^>]*)>(\\s*"+cdataRegx+")*([^<]+)?","g");
|
14
15
|
//const tagsRegx = new RegExp("<(\\/?)((\\w*:)?([\\w:\\-\._]+))([^>]*)>([^<]*)("+cdataRegx+"([^<]*))*([^<]+)?","g");
|
15
16
|
|
16
|
-
class OrderedObjParser{
|
17
|
+
export default class OrderedObjParser{
|
17
18
|
constructor(options){
|
18
19
|
this.options = options;
|
19
20
|
this.currentNode = null;
|
@@ -40,8 +41,8 @@ class OrderedObjParser{
|
|
40
41
|
"copyright" : { regex: /&(copy|#169);/g, val: "©" },
|
41
42
|
"reg" : { regex: /&(reg|#174);/g, val: "®" },
|
42
43
|
"inr" : { regex: /&(inr|#8377);/g, val: "₹" },
|
43
|
-
"num_dec": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.
|
44
|
-
"num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.
|
44
|
+
"num_dec": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.fromCodePoint(Number.parseInt(str, 10)) },
|
45
|
+
"num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCodePoint(Number.parseInt(str, 16)) },
|
45
46
|
};
|
46
47
|
this.addExternalEntities = addExternalEntities;
|
47
48
|
this.parseXml = parseXml;
|
@@ -53,6 +54,7 @@ class OrderedObjParser{
|
|
53
54
|
this.readStopNodeData = readStopNodeData;
|
54
55
|
this.saveTextToParentTag = saveTextToParentTag;
|
55
56
|
this.addChild = addChild;
|
57
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes)
|
56
58
|
}
|
57
59
|
|
58
60
|
}
|
@@ -125,15 +127,18 @@ function resolveNameSpace(tagname) {
|
|
125
127
|
const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
|
126
128
|
|
127
129
|
function buildAttributesMap(attrStr, jPath, tagName) {
|
128
|
-
if (
|
130
|
+
if (this.options.ignoreAttributes !== true && typeof attrStr === 'string') {
|
129
131
|
// attrStr = attrStr.replace(/\r?\n/g, ' ');
|
130
132
|
//attrStr = attrStr || attrStr.trim();
|
131
133
|
|
132
|
-
const matches =
|
134
|
+
const matches = getAllMatches(attrStr, attrsRegx);
|
133
135
|
const len = matches.length; //don't make it inline
|
134
136
|
const attrs = {};
|
135
137
|
for (let i = 0; i < len; i++) {
|
136
138
|
const attrName = this.resolveNameSpace(matches[i][1]);
|
139
|
+
if (this.ignoreAttributesFn(attrName, jPath)) {
|
140
|
+
continue
|
141
|
+
}
|
137
142
|
let oldVal = matches[i][4];
|
138
143
|
let aName = this.options.attributeNamePrefix + attrName;
|
139
144
|
if (attrName.length) {
|
@@ -241,8 +246,7 @@ const parseXml = function(xmlData) {
|
|
241
246
|
if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){
|
242
247
|
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
|
243
248
|
}
|
244
|
-
this.addChild(currentNode, childNode, jPath)
|
245
|
-
|
249
|
+
this.addChild(currentNode, childNode, jPath, i);
|
246
250
|
}
|
247
251
|
|
248
252
|
|
@@ -307,6 +311,7 @@ const parseXml = function(xmlData) {
|
|
307
311
|
if(tagName !== xmlObj.tagname){
|
308
312
|
jPath += jPath ? "." + tagName : tagName;
|
309
313
|
}
|
314
|
+
const startIndex = i;
|
310
315
|
if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
|
311
316
|
let tagContent = "";
|
312
317
|
//self-closing tag
|
@@ -335,6 +340,7 @@ const parseXml = function(xmlData) {
|
|
335
340
|
}
|
336
341
|
|
337
342
|
const childNode = new xmlNode(tagName);
|
343
|
+
|
338
344
|
if(tagName !== tagExp && attrExpPresent){
|
339
345
|
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
340
346
|
}
|
@@ -345,7 +351,7 @@ const parseXml = function(xmlData) {
|
|
345
351
|
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
346
352
|
childNode.add(this.options.textNodeName, tagContent);
|
347
353
|
|
348
|
-
this.addChild(currentNode, childNode, jPath)
|
354
|
+
this.addChild(currentNode, childNode, jPath, startIndex);
|
349
355
|
}else{
|
350
356
|
//selfClosing tag
|
351
357
|
if(tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1){
|
@@ -365,7 +371,7 @@ const parseXml = function(xmlData) {
|
|
365
371
|
if(tagName !== tagExp && attrExpPresent){
|
366
372
|
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
367
373
|
}
|
368
|
-
this.addChild(currentNode, childNode, jPath)
|
374
|
+
this.addChild(currentNode, childNode, jPath, startIndex);
|
369
375
|
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
370
376
|
}
|
371
377
|
//opening tag
|
@@ -376,7 +382,7 @@ const parseXml = function(xmlData) {
|
|
376
382
|
if(tagName !== tagExp && attrExpPresent){
|
377
383
|
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
378
384
|
}
|
379
|
-
this.addChild(currentNode, childNode, jPath)
|
385
|
+
this.addChild(currentNode, childNode, jPath, startIndex);
|
380
386
|
currentNode = childNode;
|
381
387
|
}
|
382
388
|
textData = "";
|
@@ -390,14 +396,16 @@ const parseXml = function(xmlData) {
|
|
390
396
|
return xmlObj.child;
|
391
397
|
}
|
392
398
|
|
393
|
-
function addChild(currentNode, childNode, jPath){
|
399
|
+
function addChild(currentNode, childNode, jPath, startIndex){
|
400
|
+
// unset startIndex if not requested
|
401
|
+
if (!this.options.captureMetaData) startIndex = undefined;
|
394
402
|
const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"])
|
395
403
|
if(result === false){
|
396
|
-
}else if(typeof result === "string"){
|
404
|
+
} else if(typeof result === "string"){
|
397
405
|
childNode.tagname = result
|
398
|
-
currentNode.addChild(childNode);
|
406
|
+
currentNode.addChild(childNode, startIndex);
|
399
407
|
}else{
|
400
|
-
currentNode.addChild(childNode);
|
408
|
+
currentNode.addChild(childNode, startIndex);
|
401
409
|
}
|
402
410
|
}
|
403
411
|
|
@@ -424,7 +432,7 @@ const replaceEntitiesValue = function(val){
|
|
424
432
|
}
|
425
433
|
function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
|
426
434
|
if (textData) { //store previously collected data as textNode
|
427
|
-
if(isLeafNode === undefined) isLeafNode =
|
435
|
+
if(isLeafNode === undefined) isLeafNode = currentNode.child.length === 0
|
428
436
|
|
429
437
|
textData = this.parseTextData(textData,
|
430
438
|
currentNode.tagname,
|
@@ -589,13 +597,10 @@ function parseValue(val, shouldParse, options) {
|
|
589
597
|
else if(newval === 'false' ) return false;
|
590
598
|
else return toNumber(val, options);
|
591
599
|
} else {
|
592
|
-
if (
|
600
|
+
if (isExist(val)) {
|
593
601
|
return val;
|
594
602
|
} else {
|
595
603
|
return '';
|
596
604
|
}
|
597
605
|
}
|
598
606
|
}
|
599
|
-
|
600
|
-
|
601
|
-
module.exports = OrderedObjParser;
|
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { buildOptions} from './OptionsBuilder.js';
|
2
|
+
import OrderedObjParser from './OrderedObjParser.js';
|
3
|
+
import prettify from './node2json.js';
|
4
|
+
import {validate} from "../validator.js";
|
5
|
+
import XmlNode from './xmlNode.js';
|
5
6
|
|
6
|
-
class XMLParser{
|
7
|
+
export default class XMLParser{
|
7
8
|
|
8
9
|
constructor(options){
|
9
10
|
this.externalEntities = {};
|
@@ -25,7 +26,7 @@ class XMLParser{
|
|
25
26
|
if( validationOption){
|
26
27
|
if(validationOption === true) validationOption = {}; //validate with default options
|
27
28
|
|
28
|
-
const result =
|
29
|
+
const result = validate(xmlData, validationOption);
|
29
30
|
if (result !== true) {
|
30
31
|
throw Error( `${result.err.msg}:${result.err.line}:${result.err.col}` )
|
31
32
|
}
|
@@ -53,6 +54,18 @@ class XMLParser{
|
|
53
54
|
this.externalEntities[key] = value;
|
54
55
|
}
|
55
56
|
}
|
56
|
-
}
|
57
57
|
|
58
|
-
|
58
|
+
/**
|
59
|
+
* Returns a Symbol that can be used to access the metadata
|
60
|
+
* property on a node.
|
61
|
+
*
|
62
|
+
* If Symbol is not available in the environment, an ordinary property is used
|
63
|
+
* and the name of the property is here returned.
|
64
|
+
*
|
65
|
+
* The XMLMetaData property is only present when `captureMetaData`
|
66
|
+
* is true in the options.
|
67
|
+
*/
|
68
|
+
static getMetaDataSymbol() {
|
69
|
+
return XmlNode.getMetaDataSymbol();
|
70
|
+
}
|
71
|
+
}
|
@@ -1,12 +1,16 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
import XmlNode from './xmlNode.js';
|
4
|
+
|
5
|
+
const METADATA_SYMBOL = XmlNode.getMetaDataSymbol();
|
6
|
+
|
3
7
|
/**
|
4
8
|
*
|
5
9
|
* @param {array} node
|
6
10
|
* @param {any} options
|
7
11
|
* @returns
|
8
12
|
*/
|
9
|
-
function prettify(node, options){
|
13
|
+
export default function prettify(node, options){
|
10
14
|
return compress( node, options);
|
11
15
|
}
|
12
16
|
|
@@ -36,6 +40,9 @@ function compress(arr, options, jPath){
|
|
36
40
|
|
37
41
|
let val = compress(tagObj[property], options, newJpath);
|
38
42
|
const isLeaf = isLeafTag(val, options);
|
43
|
+
if (tagObj[METADATA_SYMBOL] !== undefined) {
|
44
|
+
val[METADATA_SYMBOL] = tagObj[METADATA_SYMBOL]; // copy over metadata
|
45
|
+
}
|
39
46
|
|
40
47
|
if(tagObj[":@"]){
|
41
48
|
assignAttributes( val, tagObj[":@"], newJpath, options);
|
@@ -110,4 +117,3 @@ function isLeafTag(obj, options){
|
|
110
117
|
|
111
118
|
return false;
|
112
119
|
}
|
113
|
-
exports.prettify = prettify;
|