@btc-embedded/cdk-extensions 0.23.4 → 0.23.5
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 +5 -5
- package/CHANGELOG.md +7 -0
- package/assets/cli/catnip.js +154 -166
- package/lib/constructs/EventPipe.js +1 -1
- package/lib/constructs/ExportedService.js +1 -1
- package/lib/constructs/S3Bucket.js +1 -1
- package/lib/constructs/SecureRestApi.js +1 -1
- package/lib/constructs/SecureRestApiV2.js +1 -1
- package/lib/constructs/api-keys/ApiKeyClientAuthorization.js +1 -1
- package/lib/constructs/api-keys/ApiKeyManagement.js +1 -1
- package/lib/constructs/api-keys/ApiKeyPreTokenHandler.js +1 -1
- package/lib/constructs/api-keys/ApiKeyStore.js +1 -1
- package/lib/extensions/ApiGatewayExtension.js +1 -1
- package/lib/extensions/ApplicationContainer.js +1 -1
- package/lib/extensions/ApplicationLoadBalancerExtension.js +1 -1
- package/lib/extensions/ApplicationLoadBalancerExtensionV2.js +1 -1
- package/lib/extensions/CloudMapExtension.js +1 -1
- package/lib/extensions/DeactivatableServiceExtension.js +1 -1
- package/lib/extensions/DeploymentConfigExtension.js +1 -1
- package/lib/extensions/DocumentDbAccessExtension.js +1 -1
- package/lib/extensions/DomainEventMessagingExtension.js +1 -1
- package/lib/extensions/EfsMountExtension.js +1 -1
- package/lib/extensions/ExtraContainerExtension.js +1 -1
- package/lib/extensions/HTTPApiExtension.js +1 -1
- package/lib/extensions/LogExtension.js +1 -1
- package/lib/extensions/ModifyContainerDefinitionExtension.js +1 -1
- package/lib/extensions/ModifyTaskDefinitionExtension.js +1 -1
- package/lib/extensions/OpenIdExtension.js +1 -1
- package/lib/extensions/OpenTelemetryExtension.js +1 -1
- package/lib/extensions/PostgresDbAccessExtension.js +1 -1
- package/lib/extensions/SharedVolumeExtension.js +1 -1
- package/lib/extensions/TcpKeepAliveExtension.js +1 -1
- package/lib/platform/ApiGateway.js +1 -1
- package/lib/platform/ApiGatewayVpcLink.js +2 -2
- package/lib/platform/ApplicationLoadBalancer.js +1 -1
- package/lib/platform/ApplicationLoadBalancerV2.d.ts +1 -0
- package/lib/platform/ApplicationLoadBalancerV2.js +10 -3
- package/lib/platform/AuroraPostgresDB.js +2 -2
- package/lib/platform/BTCLogGroup.js +1 -1
- package/lib/platform/CognitoUserPool.js +2 -2
- package/lib/platform/DefaultUserPoolClients.js +1 -1
- package/lib/platform/DocumentDB.js +2 -2
- package/lib/platform/EcsCluster.js +1 -1
- package/lib/platform/EfsFileSystem.js +1 -1
- package/lib/platform/HostedZone.js +1 -1
- package/lib/platform/PrivateDnsNamespace.js +1 -1
- package/lib/platform/ResourceServer.js +1 -1
- package/lib/platform/Vpc.js +1 -1
- package/lib/platform/VpcV2.js +1 -1
- package/lib/stacks/ApplicationStack.js +1 -1
- package/lib/utils/BasePlatformStackResolver.js +1 -1
- package/lib/utils/StackParameter.js +1 -1
- package/node_modules/@nodable/entities/README.md +41 -0
- package/node_modules/@nodable/entities/package.json +54 -0
- package/node_modules/@nodable/entities/src/EntityDecoder.js +543 -0
- package/node_modules/@nodable/entities/src/EntityEncoder.js +194 -0
- package/node_modules/@nodable/entities/src/entities.js +1177 -0
- package/node_modules/@nodable/entities/src/entityTries.js +49 -0
- package/node_modules/@nodable/entities/src/index.d.ts +264 -0
- package/node_modules/@nodable/entities/src/index.js +29 -0
- package/node_modules/fast-xml-builder/CHANGELOG.md +40 -0
- package/node_modules/fast-xml-builder/LICENSE +21 -0
- package/node_modules/fast-xml-builder/README.md +74 -0
- package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
- package/node_modules/fast-xml-builder/lib/fxb.d.cts +270 -0
- package/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
- package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
- package/node_modules/fast-xml-builder/package.json +81 -0
- package/node_modules/fast-xml-builder/src/fxb.d.ts +270 -0
- package/node_modules/fast-xml-builder/src/fxb.js +599 -0
- package/node_modules/fast-xml-builder/src/ignoreAttributes.js +18 -0
- package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +359 -0
- package/node_modules/fast-xml-builder/src/util.js +16 -0
- package/node_modules/fast-xml-parser/CHANGELOG.md +165 -0
- package/node_modules/fast-xml-parser/README.md +21 -44
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.cjs +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.d.cts +343 -31
- package/node_modules/fast-xml-parser/lib/fxp.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -1
- package/node_modules/fast-xml-parser/lib/fxparser.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -1
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js +1 -1
- package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -1
- package/node_modules/fast-xml-parser/package.json +13 -8
- package/node_modules/fast-xml-parser/src/fxp.d.ts +335 -30
- package/node_modules/fast-xml-parser/src/fxp.js +1 -1
- package/node_modules/fast-xml-parser/src/util.js +18 -25
- package/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +89 -87
- package/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +10 -10
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +23 -23
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +29 -29
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +1 -1
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +39 -39
- package/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +21 -21
- package/node_modules/fast-xml-parser/src/v6/XMLParser.js +22 -22
- package/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +85 -85
- package/node_modules/fast-xml-parser/src/validator.js +34 -34
- package/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +5 -284
- package/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +335 -293
- package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +160 -43
- package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +540 -308
- package/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +26 -26
- package/node_modules/fast-xml-parser/src/xmlparser/node2json.js +99 -41
- package/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +10 -10
- package/node_modules/path-expression-matcher/LICENSE +21 -0
- package/node_modules/path-expression-matcher/README.md +872 -0
- package/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
- package/node_modules/path-expression-matcher/lib/pem.d.cts +634 -0
- package/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
- package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
- package/node_modules/path-expression-matcher/package.json +78 -0
- package/node_modules/path-expression-matcher/src/Expression.js +232 -0
- package/node_modules/path-expression-matcher/src/ExpressionSet.js +209 -0
- package/node_modules/path-expression-matcher/src/Matcher.js +570 -0
- package/node_modules/path-expression-matcher/src/index.d.ts +523 -0
- package/node_modules/path-expression-matcher/src/index.js +29 -0
- package/node_modules/strnum/CHANGELOG.md +12 -2
- package/node_modules/strnum/README.md +1 -0
- package/node_modules/strnum/package.json +5 -4
- package/node_modules/strnum/strnum.js +99 -65
- package/node_modules/xml-naming/README.md +189 -0
- package/node_modules/xml-naming/package.json +54 -0
- package/node_modules/xml-naming/src/index.d.ts +74 -0
- package/node_modules/xml-naming/src/index.js +270 -0
- package/package.json +3 -2
- package/renovate.json5 +1 -0
- package/node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js +0 -134
- package/node_modules/strnum/.github/SECURITY.md +0 -5
- package/node_modules/strnum/.vscode/launch.json +0 -25
- package/node_modules/strnum/algo.stflow +0 -84
- package/node_modules/strnum/strnum.test.js +0 -173
- package/node_modules/strnum/test.js +0 -9
- /package/node_modules/{fast-xml-parser/src/xmlbuilder → fast-xml-builder/src}/prettifyJs2Xml.js +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xml-naming
|
|
3
|
+
* Validates XML Name productions as defined in the XML 1.0 and 1.1 specifications.
|
|
4
|
+
* Covers: Name, NCName, QName, NMToken, NMTokens
|
|
5
|
+
*
|
|
6
|
+
* XML 1.0 spec: https://www.w3.org/TR/xml/#NT-Name
|
|
7
|
+
* XML 1.1 spec: https://www.w3.org/TR/xml11/#NT-NameStartChar
|
|
8
|
+
* XML NS spec: https://www.w3.org/TR/xml-names/#NT-NCName
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Character class strings — XML 1.0
|
|
13
|
+
//
|
|
14
|
+
// NameStartChar ::= ":" | [A-Z] | "_" | [a-z]
|
|
15
|
+
// | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF]
|
|
16
|
+
// | [#x370-#x37D] | [#x37F-#x1FFF] <- split to exclude #x0487
|
|
17
|
+
// | [#x200C-#x200D]
|
|
18
|
+
// | [#x2070-#x218F] | [#x2C00-#x2FEF]
|
|
19
|
+
// | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD]
|
|
20
|
+
//
|
|
21
|
+
// NameChar ::= NameStartChar | "-" | "." | [0-9]
|
|
22
|
+
// | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
23
|
+
//
|
|
24
|
+
// Note: \u0487 (Combining Cyrillic Millions Sign) was added in Unicode 4.0,
|
|
25
|
+
// after XML 1.0 was defined against Unicode 2.0. It falls inside the range
|
|
26
|
+
// \u037F-\u1FFF but must be excluded. We split that range into
|
|
27
|
+
// \u037F-\u0486 and \u0488-\u1FFF to exclude it explicitly.
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
const nameStartChar10 =
|
|
31
|
+
':A-Za-z_' +
|
|
32
|
+
'\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF' +
|
|
33
|
+
'\u0370-\u037D' +
|
|
34
|
+
'\u037F-\u0486\u0488-\u1FFF' + // split to exclude \u0487
|
|
35
|
+
'\u200C-\u200D' +
|
|
36
|
+
'\u2070-\u218F' +
|
|
37
|
+
'\u2C00-\u2FEF' +
|
|
38
|
+
'\u3001-\uD7FF' +
|
|
39
|
+
'\uF900-\uFDCF' +
|
|
40
|
+
'\uFDF0-\uFFFD';
|
|
41
|
+
|
|
42
|
+
const nameChar10 =
|
|
43
|
+
nameStartChar10 +
|
|
44
|
+
'\\-\\.\\d' +
|
|
45
|
+
'\u00B7' +
|
|
46
|
+
'\u0300-\u036F' +
|
|
47
|
+
'\u203F-\u2040';
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Character class strings — XML 1.1
|
|
51
|
+
//
|
|
52
|
+
// Differences from XML 1.0:
|
|
53
|
+
//
|
|
54
|
+
// NameStartChar:
|
|
55
|
+
// 1.0 has split ranges: \u00C0-\u00D6, \u00D8-\u00F6, \u00F8-\u02FF
|
|
56
|
+
// 1.1 merges them into: \u00C0-\u02FF
|
|
57
|
+
// (\u00D7 x and \u00F7 / are division symbols, excluded in both versions)
|
|
58
|
+
//
|
|
59
|
+
// 1.0 tops out at \uFFFD (BMP only)
|
|
60
|
+
// 1.1 adds \u{10000}-\u{EFFFF} (supplementary planes)
|
|
61
|
+
// These require the /u flag on the RegExp — see buildRegexes below.
|
|
62
|
+
//
|
|
63
|
+
// NameChar:
|
|
64
|
+
// 1.1 adds \u0487 (Combining Cyrillic Millions Sign, added in Unicode 4.0)
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
const nameStartChar11 =
|
|
68
|
+
':A-Za-z_' +
|
|
69
|
+
'\u00C0-\u02FF' + // merged — 1.0 had three split ranges here
|
|
70
|
+
'\u0370-\u037D' +
|
|
71
|
+
'\u037F-\u0486\u0488-\u1FFF' + // split to exclude \u0487 (combining mark, never a NameStartChar)
|
|
72
|
+
'\u200C-\u200D' +
|
|
73
|
+
'\u2070-\u218F' +
|
|
74
|
+
'\u2C00-\u2FEF' +
|
|
75
|
+
'\u3001-\uD7FF' +
|
|
76
|
+
'\uF900-\uFDCF' +
|
|
77
|
+
'\uFDF0-\uFFFD' +
|
|
78
|
+
'\u{10000}-\u{EFFFF}'; // supplementary planes — REQUIRES /u flag on RegExp
|
|
79
|
+
|
|
80
|
+
const nameChar11 =
|
|
81
|
+
nameStartChar11 +
|
|
82
|
+
'\\-\\.\\d' +
|
|
83
|
+
'\u00B7' +
|
|
84
|
+
'\u0300-\u036F' +
|
|
85
|
+
'\u0487' + // Combining Cyrillic Millions Sign — valid in 1.1, not 1.0
|
|
86
|
+
'\u203F-\u2040';
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Regex builders
|
|
90
|
+
//
|
|
91
|
+
// XML 1.0 regexes: no flags — BMP only, standard JS regex behaviour.
|
|
92
|
+
// XML 1.1 regexes: /u flag — required for \u{10000}-\u{EFFFF} to match actual
|
|
93
|
+
// supplementary code points rather than lone surrogates (which are illegal XML).
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
const buildRegexes = (startChar, char, flags = '') => {
|
|
97
|
+
const ncStart = startChar.replace(':', '');
|
|
98
|
+
const ncChar = char.replace(':', '');
|
|
99
|
+
const ncNamePat = `[${ncStart}][${ncChar}]*`;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
name: new RegExp(`^[${startChar}][${char}]*$`, flags),
|
|
103
|
+
ncName: new RegExp(`^${ncNamePat}$`, flags),
|
|
104
|
+
qName: new RegExp(`^${ncNamePat}(?::${ncNamePat})?$`, flags),
|
|
105
|
+
nmToken: new RegExp(`^[${char}]+$`, flags),
|
|
106
|
+
nmTokens: new RegExp(`^[${char}]+(?:\\s+[${char}]+)*$`, flags),
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const regexes10 = buildRegexes(nameStartChar10, nameChar10); // no /u — BMP only
|
|
111
|
+
const regexes11 = buildRegexes(nameStartChar11, nameChar11, 'u'); // /u — enables \u{10000}-\u{EFFFF}
|
|
112
|
+
|
|
113
|
+
const getRegexes = (xmlVersion = '1.0') =>
|
|
114
|
+
xmlVersion === '1.1' ? regexes11 : regexes10;
|
|
115
|
+
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// Boolean validators
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Returns true if the string is a valid XML Name.
|
|
122
|
+
* Colons are allowed anywhere (Name production).
|
|
123
|
+
* Used for: DOCTYPE entity names, notation names, DTD element declarations.
|
|
124
|
+
*/
|
|
125
|
+
export const name = (str, { xmlVersion = '1.0' } = {}) =>
|
|
126
|
+
getRegexes(xmlVersion).name.test(str);
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Returns true if the string is a valid NCName (Non-Colonized Name).
|
|
130
|
+
* Colons are not permitted.
|
|
131
|
+
* Used for: namespace prefixes, local names, SVG id attributes.
|
|
132
|
+
*/
|
|
133
|
+
export const ncName = (str, { xmlVersion = '1.0' } = {}) =>
|
|
134
|
+
getRegexes(xmlVersion).ncName.test(str);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Returns true if the string is a valid QName (Qualified Name).
|
|
138
|
+
* Allows exactly one colon as a prefix separator: prefix:localName.
|
|
139
|
+
* Used for: element and attribute names in namespace-aware XML/SVG.
|
|
140
|
+
*/
|
|
141
|
+
export const qName = (str, { xmlVersion = '1.0' } = {}) =>
|
|
142
|
+
getRegexes(xmlVersion).qName.test(str);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Returns true if the string is a valid NMToken.
|
|
146
|
+
* Like Name but no restriction on the first character.
|
|
147
|
+
* Used for: DTD NMTOKEN attribute values.
|
|
148
|
+
*/
|
|
149
|
+
export const nmToken = (str, { xmlVersion = '1.0' } = {}) =>
|
|
150
|
+
getRegexes(xmlVersion).nmToken.test(str);
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Returns true if the string is a valid NMTokens value.
|
|
154
|
+
* A whitespace-separated list of NMToken values.
|
|
155
|
+
* Used for: DTD NMTOKENS attribute values.
|
|
156
|
+
*/
|
|
157
|
+
export const nmTokens = (str, { xmlVersion = '1.0' } = {}) =>
|
|
158
|
+
getRegexes(xmlVersion).nmTokens.test(str);
|
|
159
|
+
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
// Diagnostic validator
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
|
|
164
|
+
const PRODUCTIONS = ['name', 'ncName', 'qName', 'nmToken', 'nmTokens'];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Validates a string against a named production and returns a detailed result.
|
|
168
|
+
*
|
|
169
|
+
* @param {string} str
|
|
170
|
+
* @param {'name'|'ncName'|'qName'|'nmToken'|'nmTokens'} production
|
|
171
|
+
* @param {{ xmlVersion?: '1.0'|'1.1' }} [opts]
|
|
172
|
+
* @returns {{ valid: boolean, production: string, input: string, reason?: string, position?: number }}
|
|
173
|
+
*/
|
|
174
|
+
export const validate = (str, production, { xmlVersion = '1.0' } = {}) => {
|
|
175
|
+
if (!PRODUCTIONS.includes(production)) {
|
|
176
|
+
throw new TypeError(
|
|
177
|
+
`Unknown production "${production}". Must be one of: ${PRODUCTIONS.join(', ')}`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const validators = { name, ncName, qName, nmToken, nmTokens };
|
|
182
|
+
const isValid = validators[production](str, { xmlVersion });
|
|
183
|
+
|
|
184
|
+
if (isValid) return { valid: true, production, input: str };
|
|
185
|
+
|
|
186
|
+
let reason = 'Does not match the production rules';
|
|
187
|
+
let position;
|
|
188
|
+
|
|
189
|
+
if (str.length === 0) {
|
|
190
|
+
reason = 'Input is empty';
|
|
191
|
+
} else if (production === 'ncName' && str.includes(':')) {
|
|
192
|
+
position = str.indexOf(':');
|
|
193
|
+
reason = 'Colon is not allowed in NCName';
|
|
194
|
+
} else if (production === 'qName' && str.startsWith(':')) {
|
|
195
|
+
reason = 'QName cannot start with a colon';
|
|
196
|
+
position = 0;
|
|
197
|
+
} else if (production === 'qName' && str.endsWith(':')) {
|
|
198
|
+
reason = 'QName cannot end with a colon';
|
|
199
|
+
position = str.length - 1;
|
|
200
|
+
} else if (production === 'qName' && (str.match(/:/g) || []).length > 1) {
|
|
201
|
+
reason = 'QName can have at most one colon';
|
|
202
|
+
position = str.lastIndexOf(':');
|
|
203
|
+
} else if (
|
|
204
|
+
['name', 'ncName', 'qName'].includes(production) &&
|
|
205
|
+
!/^[:A-Za-z_\u00C0-\uFFFD]/.test(str[0])
|
|
206
|
+
) {
|
|
207
|
+
reason = `First character "${str[0]}" is not a valid NameStartChar`;
|
|
208
|
+
position = 0;
|
|
209
|
+
} else {
|
|
210
|
+
for (let i = 0; i < str.length; i++) {
|
|
211
|
+
if (!/[\w\-\\.:\u00B7\u00C0-\uFFFD]/.test(str[i])) {
|
|
212
|
+
reason = `Character "${str[i]}" at position ${i} is not a valid NameChar`;
|
|
213
|
+
position = i;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return { valid: false, production, input: str, reason, position };
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// ---------------------------------------------------------------------------
|
|
223
|
+
// Batch validator
|
|
224
|
+
// ---------------------------------------------------------------------------
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Validates an array of strings against a named production.
|
|
228
|
+
*
|
|
229
|
+
* @param {string[]} strings
|
|
230
|
+
* @param {'name'|'ncName'|'qName'|'nmToken'|'nmTokens'} production
|
|
231
|
+
* @param {{ xmlVersion?: '1.0'|'1.1' }} [opts]
|
|
232
|
+
* @returns {Array<{ valid: boolean, production: string, input: string, reason?: string, position?: number }>}
|
|
233
|
+
*/
|
|
234
|
+
export const validateAll = (strings, production, opts = {}) =>
|
|
235
|
+
strings.map(str => validate(str, production, opts));
|
|
236
|
+
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
// Sanitizer
|
|
239
|
+
// ---------------------------------------------------------------------------
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Transforms an invalid string into the nearest valid XML name for the given production.
|
|
243
|
+
*
|
|
244
|
+
* @param {string} str
|
|
245
|
+
* @param {'name'|'ncName'|'qName'|'nmToken'|'nmTokens'} production
|
|
246
|
+
* @param {{ replacement?: string }} [opts]
|
|
247
|
+
* @returns {string}
|
|
248
|
+
*/
|
|
249
|
+
export const sanitize = (str, production = 'name', { replacement = '_' } = {}) => {
|
|
250
|
+
if (!str) return replacement;
|
|
251
|
+
|
|
252
|
+
let result = str;
|
|
253
|
+
|
|
254
|
+
// Strip colons for NCName
|
|
255
|
+
if (production === 'ncName') {
|
|
256
|
+
result = result.replace(/:/g, '');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Replace illegal characters
|
|
260
|
+
result = result.replace(/[^\w\-\.:\u00B7\u00C0-\uFFFD]/g, replacement);
|
|
261
|
+
|
|
262
|
+
// Fix invalid start character for Name / NCName / QName
|
|
263
|
+
if (production !== 'nmToken' && production !== 'nmTokens') {
|
|
264
|
+
if (/^[\-\.\d]/.test(result)) {
|
|
265
|
+
result = replacement + result;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return result || replacement;
|
|
270
|
+
};
|
package/package.json
CHANGED
|
@@ -141,14 +141,15 @@
|
|
|
141
141
|
"zod"
|
|
142
142
|
],
|
|
143
143
|
"resolutions": {
|
|
144
|
-
"@smithy/types": "^4.12.0"
|
|
144
|
+
"@smithy/types": "^4.12.0",
|
|
145
|
+
"fast-xml-parser": "^5.3.5"
|
|
145
146
|
},
|
|
146
147
|
"keywords": [
|
|
147
148
|
"cdk"
|
|
148
149
|
],
|
|
149
150
|
"main": "lib/index.js",
|
|
150
151
|
"license": "Apache-2.0",
|
|
151
|
-
"version": "0.23.
|
|
152
|
+
"version": "0.23.5",
|
|
152
153
|
"jest": {
|
|
153
154
|
"coverageProvider": "v8",
|
|
154
155
|
"maxWorkers": 4,
|
package/renovate.json5
CHANGED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
const EOL = "\n";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {array} jArray
|
|
6
|
-
* @param {any} options
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export default function toXml(jArray, options) {
|
|
10
|
-
let indentation = "";
|
|
11
|
-
if (options.format && options.indentBy.length > 0) {
|
|
12
|
-
indentation = EOL;
|
|
13
|
-
}
|
|
14
|
-
return arrToStr(jArray, options, "", indentation);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function arrToStr(arr, options, jPath, indentation) {
|
|
18
|
-
let xmlStr = "";
|
|
19
|
-
let isPreviousElementTag = false;
|
|
20
|
-
|
|
21
|
-
for (let i = 0; i < arr.length; i++) {
|
|
22
|
-
const tagObj = arr[i];
|
|
23
|
-
const tagName = propName(tagObj);
|
|
24
|
-
if(tagName === undefined) continue;
|
|
25
|
-
|
|
26
|
-
let newJPath = "";
|
|
27
|
-
if (jPath.length === 0) newJPath = tagName
|
|
28
|
-
else newJPath = `${jPath}.${tagName}`;
|
|
29
|
-
|
|
30
|
-
if (tagName === options.textNodeName) {
|
|
31
|
-
let tagText = tagObj[tagName];
|
|
32
|
-
if (!isStopNode(newJPath, options)) {
|
|
33
|
-
tagText = options.tagValueProcessor(tagName, tagText);
|
|
34
|
-
tagText = replaceEntitiesValue(tagText, options);
|
|
35
|
-
}
|
|
36
|
-
if (isPreviousElementTag) {
|
|
37
|
-
xmlStr += indentation;
|
|
38
|
-
}
|
|
39
|
-
xmlStr += tagText;
|
|
40
|
-
isPreviousElementTag = false;
|
|
41
|
-
continue;
|
|
42
|
-
} else if (tagName === options.cdataPropName) {
|
|
43
|
-
if (isPreviousElementTag) {
|
|
44
|
-
xmlStr += indentation;
|
|
45
|
-
}
|
|
46
|
-
xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
|
|
47
|
-
isPreviousElementTag = false;
|
|
48
|
-
continue;
|
|
49
|
-
} else if (tagName === options.commentPropName) {
|
|
50
|
-
xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;
|
|
51
|
-
isPreviousElementTag = true;
|
|
52
|
-
continue;
|
|
53
|
-
} else if (tagName[0] === "?") {
|
|
54
|
-
const attStr = attr_to_str(tagObj[":@"], options);
|
|
55
|
-
const tempInd = tagName === "?xml" ? "" : indentation;
|
|
56
|
-
let piTextNodeName = tagObj[tagName][0][options.textNodeName];
|
|
57
|
-
piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : ""; //remove extra spacing
|
|
58
|
-
xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr}?>`;
|
|
59
|
-
isPreviousElementTag = true;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
let newIdentation = indentation;
|
|
63
|
-
if (newIdentation !== "") {
|
|
64
|
-
newIdentation += options.indentBy;
|
|
65
|
-
}
|
|
66
|
-
const attStr = attr_to_str(tagObj[":@"], options);
|
|
67
|
-
const tagStart = indentation + `<${tagName}${attStr}`;
|
|
68
|
-
const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
|
|
69
|
-
if (options.unpairedTags.indexOf(tagName) !== -1) {
|
|
70
|
-
if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
|
|
71
|
-
else xmlStr += tagStart + "/>";
|
|
72
|
-
} else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
|
|
73
|
-
xmlStr += tagStart + "/>";
|
|
74
|
-
} else if (tagValue && tagValue.endsWith(">")) {
|
|
75
|
-
xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
|
|
76
|
-
} else {
|
|
77
|
-
xmlStr += tagStart + ">";
|
|
78
|
-
if (tagValue && indentation !== "" && (tagValue.includes("/>") || tagValue.includes("</"))) {
|
|
79
|
-
xmlStr += indentation + options.indentBy + tagValue + indentation;
|
|
80
|
-
} else {
|
|
81
|
-
xmlStr += tagValue;
|
|
82
|
-
}
|
|
83
|
-
xmlStr += `</${tagName}>`;
|
|
84
|
-
}
|
|
85
|
-
isPreviousElementTag = true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return xmlStr;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function propName(obj) {
|
|
92
|
-
const keys = Object.keys(obj);
|
|
93
|
-
for (let i = 0; i < keys.length; i++) {
|
|
94
|
-
const key = keys[i];
|
|
95
|
-
if(!obj.hasOwnProperty(key)) continue;
|
|
96
|
-
if (key !== ":@") return key;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function attr_to_str(attrMap, options) {
|
|
101
|
-
let attrStr = "";
|
|
102
|
-
if (attrMap && !options.ignoreAttributes) {
|
|
103
|
-
for (let attr in attrMap) {
|
|
104
|
-
if(!attrMap.hasOwnProperty(attr)) continue;
|
|
105
|
-
let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
|
|
106
|
-
attrVal = replaceEntitiesValue(attrVal, options);
|
|
107
|
-
if (attrVal === true && options.suppressBooleanAttributes) {
|
|
108
|
-
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
|
|
109
|
-
} else {
|
|
110
|
-
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${attrVal}"`;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return attrStr;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function isStopNode(jPath, options) {
|
|
118
|
-
jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
|
|
119
|
-
let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
|
|
120
|
-
for (let index in options.stopNodes) {
|
|
121
|
-
if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function replaceEntitiesValue(textValue, options) {
|
|
127
|
-
if (textValue && textValue.length > 0 && options.processEntities) {
|
|
128
|
-
for (let i = 0; i < options.entities.length; i++) {
|
|
129
|
-
const entity = options.entities[i];
|
|
130
|
-
textValue = textValue.replace(entity.regex, entity.val);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return textValue;
|
|
134
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
If you believe you have found a security vulnerability in this repository which can be potentially harful for the users in anyway, please do not report security vulnerabilities through public GitHub issues. Instead, please report it to us as described below.
|
|
2
|
-
|
|
3
|
-
## Security contact information
|
|
4
|
-
|
|
5
|
-
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.2.0",
|
|
3
|
-
"configurations": [
|
|
4
|
-
{
|
|
5
|
-
"type": "node",
|
|
6
|
-
"request": "launch",
|
|
7
|
-
"name": "Jasmine Tests",
|
|
8
|
-
"program": "${workspaceFolder}/node_modules/jasmine/bin/jasmine.js",
|
|
9
|
-
"args": [
|
|
10
|
-
"${workspaceFolder}/spec/attr_spec.js"
|
|
11
|
-
],
|
|
12
|
-
"internalConsoleOptions": "openOnSessionStart"
|
|
13
|
-
},{
|
|
14
|
-
"type": "node",
|
|
15
|
-
"request": "launch",
|
|
16
|
-
"name": "Jasmine Tests current test file",
|
|
17
|
-
"program": "${workspaceFolder}/node_modules/jasmine/bin/jasmine.js",
|
|
18
|
-
"args": [
|
|
19
|
-
"${file}"
|
|
20
|
-
],
|
|
21
|
-
"internalConsoleOptions": "openOnSessionStart"
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
FLOW: toNumber
|
|
3
|
-
input: x, options
|
|
4
|
-
IF not string
|
|
5
|
-
END x
|
|
6
|
-
ELSE_IF should skip
|
|
7
|
-
END x
|
|
8
|
-
ELSE_IF 0
|
|
9
|
-
END 0
|
|
10
|
-
ELSE_IF hex is supported AND x is hex
|
|
11
|
-
END int of x of base 16
|
|
12
|
-
ELSE_IF possible e notation
|
|
13
|
-
FOLLOW: resolve enotation (x, trimmed x, options)
|
|
14
|
-
ELSE
|
|
15
|
-
IF match numeric pattern
|
|
16
|
-
separate sign, leading zeros, pure number
|
|
17
|
-
IF x doesn't starts with "[+-]0."
|
|
18
|
-
END number(x)
|
|
19
|
-
IF leading zeros are not allowed
|
|
20
|
-
IF leading zeros > 1
|
|
21
|
-
#00.1
|
|
22
|
-
END x
|
|
23
|
-
ELSE_IF leading zeros == 1 AND decimal is not adjacent to leading zeros
|
|
24
|
-
#06.5
|
|
25
|
-
#but not 0.65, .65, 6.0
|
|
26
|
-
END x
|
|
27
|
-
ELSE_IF str has only zeros
|
|
28
|
-
END 0
|
|
29
|
-
ELSE
|
|
30
|
-
parse x to number
|
|
31
|
-
IF parsed x == 0 or -0
|
|
32
|
-
END parsed x
|
|
33
|
-
ELSE_IF parsed x is eNotation
|
|
34
|
-
IF conversion to enotation is allowed
|
|
35
|
-
END parsed x
|
|
36
|
-
ELSE
|
|
37
|
-
END x
|
|
38
|
-
ELSE_IF floating number
|
|
39
|
-
IF parsed x is 0
|
|
40
|
-
END parsed x
|
|
41
|
-
ELSE_IF parsed x == number without leading 0s
|
|
42
|
-
#0.456. 0.79000
|
|
43
|
-
END parsed x
|
|
44
|
-
ELSE_IF parsed x is negative AND == parsed x == number without leading 0s
|
|
45
|
-
END parsed x
|
|
46
|
-
ELSE
|
|
47
|
-
END x
|
|
48
|
-
ELSE_IF leading 0s are present
|
|
49
|
-
IF parsed x == x without leading 0s
|
|
50
|
-
END parsed x
|
|
51
|
-
ELSE
|
|
52
|
-
END x
|
|
53
|
-
ELSE
|
|
54
|
-
IF parsed x == x (consider sign)
|
|
55
|
-
END parsed x
|
|
56
|
-
ELSE
|
|
57
|
-
END x
|
|
58
|
-
|
|
59
|
-
ELSE
|
|
60
|
-
END x
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
FLOW: resolve enotation
|
|
65
|
-
input: x, trimmed x, options
|
|
66
|
-
IF eNotation has not to be evaluated
|
|
67
|
-
END x
|
|
68
|
-
IF match eNotation pattern
|
|
69
|
-
extract sign, eChar, leading zeros
|
|
70
|
-
find if eChar adjacent to leading zeros
|
|
71
|
-
|
|
72
|
-
IF leading zeros > 1 AND eChar adjacent to leading zeros
|
|
73
|
-
# 00e, -00e
|
|
74
|
-
END x
|
|
75
|
-
ELSE_IF exp is `0e`, `0.e`, `-0.e`, `-0e`
|
|
76
|
-
END number(x);
|
|
77
|
-
ELSE_IF leading zeros are allowed but eChar is not adjacent to leading zeros
|
|
78
|
-
# -003e2
|
|
79
|
-
remove leading zeros
|
|
80
|
-
END number(x)
|
|
81
|
-
ELSE
|
|
82
|
-
END x
|
|
83
|
-
ELSE
|
|
84
|
-
END x
|