@cdk8s/awscdk-resolver 0.0.609 → 0.0.610
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 +3 -3
- package/node_modules/@aws-sdk/core/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- 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/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +1 -1
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +233 -43
- package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.browser.js +1 -1
- package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js +233 -43
- package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-parser.d.ts +1 -1
- package/node_modules/@aws-sdk/xml-builder/dist-types/xml-parser.d.ts +2 -1
- package/node_modules/@aws-sdk/xml-builder/package.json +4 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +518 -371
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +1 -1
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-decode.js +326 -269
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor-encode.js +192 -103
- package/node_modules/@smithy/core/dist-es/submodules/cbor/cbor.js +4 -2
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/get-value-from-text-node.js +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-decode.d.ts +4 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/cbor-encode.d.ts +8 -4
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/signature-v4/package.json +2 -2
- package/package.json +6 -6
- package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-external/nodable_entities.js +0 -333
- package/node_modules/@aws-sdk/xml-builder/dist-es/xml-external/nodable_entities.js +0 -332
- package/node_modules/@aws-sdk/xml-builder/dist-types/ts3.4/xml-external/nodable_entities.d.ts +0 -66
- package/node_modules/@aws-sdk/xml-builder/dist-types/xml-external/nodable_entities.d.ts +0 -65
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/CHANGELOG.md +0 -827
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/LICENSE +0 -21
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/README.md +0 -202
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js +0 -2
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +0 -1
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +0 -1
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.d.cts +0 -770
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +0 -2
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +0 -1
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +0 -2
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +0 -1
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js +0 -2
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +0 -1
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/package.json +0 -93
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/cli.js +0 -97
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/man.js +0 -17
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/cli/read.js +0 -43
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.d.ts +0 -739
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/fxp.js +0 -14
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/ignoreAttributes.js +0 -18
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/util.js +0 -61
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/CharsSymbol.js +0 -16
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/EntitiesParser.js +0 -106
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OptionsBuilder.js +0 -61
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/BaseOutputBuilder.js +0 -69
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsArrBuilder.js +0 -103
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsMinArrBuilder.js +0 -100
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/JsObjBuilder.js +0 -154
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/OutputBuilders/ParserOptionsBuilder.js +0 -94
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Report.js +0 -0
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPath.js +0 -81
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/TagPathMatcher.js +0 -13
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XMLParser.js +0 -83
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/Xml2JsParser.js +0 -235
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlPartReader.js +0 -210
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/XmlSpecialTagsReader.js +0 -111
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/BufferSource.js +0 -116
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/inputSource/StringSource.js +0 -121
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/EntitiesParser.js +0 -105
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParser.js +0 -22
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/booleanParserExt.js +0 -19
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/currency.js +0 -38
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/join.js +0 -13
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/number.js +0 -14
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/v6/valueParsers/trim.js +0 -6
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/validator.js +0 -425
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js +0 -6
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js +0 -407
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +0 -163
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +0 -840
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js +0 -71
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/node2json.js +0 -177
- package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/xmlNode.js +0 -40
- package/node_modules/@nodable/entities/README.md +0 -41
- package/node_modules/@nodable/entities/package.json +0 -57
- package/node_modules/@nodable/entities/src/EntityDecoder.js +0 -644
- package/node_modules/@nodable/entities/src/EntityEncoder.js +0 -194
- package/node_modules/@nodable/entities/src/entities.js +0 -1159
- package/node_modules/@nodable/entities/src/entityTries.js +0 -49
- package/node_modules/@nodable/entities/src/index.d.ts +0 -341
- package/node_modules/@nodable/entities/src/index.js +0 -29
- package/node_modules/anynum/LICENSE +0 -21
- package/node_modules/anynum/README.md +0 -142
- package/node_modules/anynum/anynum.js +0 -135
- package/node_modules/anynum/digitTable.js +0 -116
- package/node_modules/anynum/package.json +0 -42
- package/node_modules/fast-xml-builder/CHANGELOG.md +0 -40
- package/node_modules/fast-xml-builder/LICENSE +0 -21
- package/node_modules/fast-xml-builder/README.md +0 -74
- package/node_modules/fast-xml-builder/lib/fxb.cjs +0 -1
- package/node_modules/fast-xml-builder/lib/fxb.d.cts +0 -270
- package/node_modules/fast-xml-builder/lib/fxb.min.js +0 -2
- package/node_modules/fast-xml-builder/lib/fxb.min.js.map +0 -1
- package/node_modules/fast-xml-builder/package.json +0 -81
- package/node_modules/fast-xml-builder/src/fxb.d.ts +0 -270
- package/node_modules/fast-xml-builder/src/fxb.js +0 -599
- package/node_modules/fast-xml-builder/src/ignoreAttributes.js +0 -18
- package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +0 -359
- package/node_modules/fast-xml-builder/src/prettifyJs2Xml.js +0 -0
- package/node_modules/fast-xml-builder/src/util.js +0 -16
- package/node_modules/path-expression-matcher/LICENSE +0 -21
- package/node_modules/path-expression-matcher/README.md +0 -947
- package/node_modules/path-expression-matcher/lib/pem.cjs +0 -1
- package/node_modules/path-expression-matcher/lib/pem.d.cts +0 -715
- package/node_modules/path-expression-matcher/lib/pem.min.js +0 -2
- package/node_modules/path-expression-matcher/lib/pem.min.js.map +0 -1
- package/node_modules/path-expression-matcher/package.json +0 -79
- package/node_modules/path-expression-matcher/src/Expression.js +0 -232
- package/node_modules/path-expression-matcher/src/ExpressionSet.js +0 -225
- package/node_modules/path-expression-matcher/src/Matcher.js +0 -660
- package/node_modules/path-expression-matcher/src/index.d.ts +0 -589
- package/node_modules/path-expression-matcher/src/index.js +0 -29
- package/node_modules/strnum/CHANGELOG.md +0 -51
- package/node_modules/strnum/LICENSE +0 -21
- package/node_modules/strnum/README.md +0 -113
- package/node_modules/strnum/package.json +0 -36
- package/node_modules/strnum/strnum.js +0 -171
- package/node_modules/xml-naming/README.md +0 -189
- package/node_modules/xml-naming/package.json +0 -54
- package/node_modules/xml-naming/src/index.d.ts +0 -74
- package/node_modules/xml-naming/src/index.js +0 -270
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import { Expression, Matcher } from 'path-expression-matcher';
|
|
2
|
-
import { safeComment, safeCdata, escapeAttribute } from "./util.js";
|
|
3
|
-
import { qName } from 'xml-naming';
|
|
4
|
-
|
|
5
|
-
const EOL = "\n";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Detect XML version from the first element of the ordered array input.
|
|
9
|
-
* The first element must be a ?xml processing instruction with a version attribute.
|
|
10
|
-
* Returns '1.0' if not found.
|
|
11
|
-
*
|
|
12
|
-
* @param {array} jArray
|
|
13
|
-
* @param {object} options
|
|
14
|
-
*/
|
|
15
|
-
function detectXmlVersionFromArray(jArray, options) {
|
|
16
|
-
if (!Array.isArray(jArray) || jArray.length === 0) return '1.0';
|
|
17
|
-
const first = jArray[0];
|
|
18
|
-
const firstKey = propName(first);
|
|
19
|
-
if (firstKey === '?xml') {
|
|
20
|
-
const attrs = first[':@'];
|
|
21
|
-
if (attrs) {
|
|
22
|
-
const versionKey = options.attributeNamePrefix + 'version';
|
|
23
|
-
if (attrs[versionKey]) return attrs[versionKey];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return '1.0';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Resolve a tag or attribute name through sanitizeName if configured.
|
|
31
|
-
* Validation via xml-naming's qName is performed first; the sanitizeName
|
|
32
|
-
* callback is invoked only when the name is invalid. If sanitizeName is
|
|
33
|
-
* false (default), no validation occurs and the name is used as-is.
|
|
34
|
-
*
|
|
35
|
-
* @param {string} name - raw name from the JS object
|
|
36
|
-
* @param {boolean} isAttribute - true when resolving an attribute name
|
|
37
|
-
* @param {object} options
|
|
38
|
-
* @param {Matcher} matcher - current matcher state (readonly from callback perspective)
|
|
39
|
-
* @param {string} xmlVersion - '1.0' or '1.1', forwarded to xml-naming
|
|
40
|
-
*/
|
|
41
|
-
function resolveTagName(name, isAttribute, options, matcher, xmlVersion) {
|
|
42
|
-
if (!options.sanitizeName) return name;
|
|
43
|
-
if (qName(name, { xmlVersion })) return name;
|
|
44
|
-
return options.sanitizeName(name, { isAttribute, matcher: matcher.readOnly() });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {array} jArray
|
|
49
|
-
* @param {any} options
|
|
50
|
-
* @returns
|
|
51
|
-
*/
|
|
52
|
-
export default function toXml(jArray, options) {
|
|
53
|
-
let indentation = "";
|
|
54
|
-
if (options.format) {
|
|
55
|
-
indentation = EOL;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Pre-compile stopNode expressions for pattern matching
|
|
59
|
-
const stopNodeExpressions = [];
|
|
60
|
-
if (options.stopNodes && Array.isArray(options.stopNodes)) {
|
|
61
|
-
for (let i = 0; i < options.stopNodes.length; i++) {
|
|
62
|
-
const node = options.stopNodes[i];
|
|
63
|
-
if (typeof node === 'string') {
|
|
64
|
-
stopNodeExpressions.push(new Expression(node));
|
|
65
|
-
} else if (node instanceof Expression) {
|
|
66
|
-
stopNodeExpressions.push(node);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Detect XML version for use in name validation
|
|
72
|
-
const xmlVersion = detectXmlVersionFromArray(jArray, options);
|
|
73
|
-
|
|
74
|
-
// Initialize matcher for path tracking
|
|
75
|
-
const matcher = new Matcher();
|
|
76
|
-
|
|
77
|
-
return arrToStr(jArray, options, indentation, matcher, stopNodeExpressions, xmlVersion);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function arrToStr(arr, options, indentation, matcher, stopNodeExpressions, xmlVersion) {
|
|
81
|
-
let xmlStr = "";
|
|
82
|
-
let isPreviousElementTag = false;
|
|
83
|
-
|
|
84
|
-
if (options.maxNestedTags && matcher.getDepth() > options.maxNestedTags) {
|
|
85
|
-
throw new Error("Maximum nested tags exceeded");
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (!Array.isArray(arr)) {
|
|
89
|
-
// Non-array values (e.g. string tag values) should be treated as text content
|
|
90
|
-
if (arr !== undefined && arr !== null) {
|
|
91
|
-
let text = arr.toString();
|
|
92
|
-
text = replaceEntitiesValue(text, options);
|
|
93
|
-
return text;
|
|
94
|
-
}
|
|
95
|
-
return "";
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
for (let i = 0; i < arr.length; i++) {
|
|
99
|
-
const tagObj = arr[i];
|
|
100
|
-
const rawTagName = propName(tagObj);
|
|
101
|
-
if (rawTagName === undefined) continue;
|
|
102
|
-
|
|
103
|
-
// Special names are exempt from sanitizeName: internal conventions and PI tags
|
|
104
|
-
// are not user-supplied XML element names.
|
|
105
|
-
const isSpecialName = rawTagName === options.textNodeName
|
|
106
|
-
|| rawTagName === options.cdataPropName
|
|
107
|
-
|| rawTagName === options.commentPropName
|
|
108
|
-
|| rawTagName[0] === '?';
|
|
109
|
-
|
|
110
|
-
// Resolve tag name (may transform it; may throw for invalid names)
|
|
111
|
-
const tagName = isSpecialName
|
|
112
|
-
? rawTagName
|
|
113
|
-
: resolveTagName(rawTagName, false, options, matcher, xmlVersion);
|
|
114
|
-
|
|
115
|
-
// Extract attributes from ":@" property
|
|
116
|
-
const attrValues = extractAttributeValues(tagObj[":@"], options);
|
|
117
|
-
|
|
118
|
-
// Push resolved tag to matcher WITH attributes
|
|
119
|
-
matcher.push(tagName, attrValues);
|
|
120
|
-
|
|
121
|
-
// Check if this is a stop node using Expression matching
|
|
122
|
-
const isStopNode = checkStopNode(matcher, stopNodeExpressions);
|
|
123
|
-
|
|
124
|
-
if (tagName === options.textNodeName) {
|
|
125
|
-
let tagText = tagObj[rawTagName];
|
|
126
|
-
if (!isStopNode) {
|
|
127
|
-
tagText = options.tagValueProcessor(tagName, tagText);
|
|
128
|
-
tagText = replaceEntitiesValue(tagText, options);
|
|
129
|
-
}
|
|
130
|
-
if (isPreviousElementTag) {
|
|
131
|
-
xmlStr += indentation;
|
|
132
|
-
}
|
|
133
|
-
xmlStr += tagText;
|
|
134
|
-
isPreviousElementTag = false;
|
|
135
|
-
matcher.pop();
|
|
136
|
-
continue;
|
|
137
|
-
} else if (tagName === options.cdataPropName) {
|
|
138
|
-
if (isPreviousElementTag) {
|
|
139
|
-
xmlStr += indentation;
|
|
140
|
-
}
|
|
141
|
-
const val = tagObj[rawTagName][0][options.textNodeName];
|
|
142
|
-
const safeVal = safeCdata(val);
|
|
143
|
-
xmlStr += `<![CDATA[${safeVal}]]>`;
|
|
144
|
-
isPreviousElementTag = false;
|
|
145
|
-
matcher.pop();
|
|
146
|
-
continue;
|
|
147
|
-
} else if (tagName === options.commentPropName) {
|
|
148
|
-
const val = tagObj[rawTagName][0][options.textNodeName];
|
|
149
|
-
const safeVal = safeComment(val);
|
|
150
|
-
xmlStr += indentation + `<!--${safeVal}-->`;
|
|
151
|
-
isPreviousElementTag = true;
|
|
152
|
-
matcher.pop();
|
|
153
|
-
continue;
|
|
154
|
-
} else if (tagName[0] === "?") {
|
|
155
|
-
const attStr = attr_to_str(tagObj[":@"], options, isStopNode, matcher, xmlVersion);
|
|
156
|
-
const tempInd = tagName === "?xml" ? "" : indentation;
|
|
157
|
-
// Text node content on PI/XML declaration tags is intentionally ignored.
|
|
158
|
-
// Only attributes are valid on these tags per the XML spec.
|
|
159
|
-
xmlStr += tempInd + `<${tagName}${attStr}?>`;
|
|
160
|
-
isPreviousElementTag = true;
|
|
161
|
-
matcher.pop();
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
let newIdentation = indentation;
|
|
166
|
-
if (newIdentation !== "") {
|
|
167
|
-
newIdentation += options.indentBy;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Pass isStopNode to attr_to_str so attributes are also not processed for stopNodes
|
|
171
|
-
const attStr = attr_to_str(tagObj[":@"], options, isStopNode, matcher, xmlVersion);
|
|
172
|
-
const tagStart = indentation + `<${tagName}${attStr}`;
|
|
173
|
-
|
|
174
|
-
// If this is a stopNode, get raw content without processing
|
|
175
|
-
let tagValue;
|
|
176
|
-
if (isStopNode) {
|
|
177
|
-
tagValue = getRawContent(tagObj[rawTagName], options);
|
|
178
|
-
} else {
|
|
179
|
-
tagValue = arrToStr(tagObj[rawTagName], options, newIdentation, matcher, stopNodeExpressions, xmlVersion);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (options.unpairedTags.indexOf(tagName) !== -1) {
|
|
183
|
-
if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
|
|
184
|
-
else xmlStr += tagStart + "/>";
|
|
185
|
-
} else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
|
|
186
|
-
xmlStr += tagStart + "/>";
|
|
187
|
-
} else if (tagValue && tagValue.endsWith(">")) {
|
|
188
|
-
xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
|
|
189
|
-
} else {
|
|
190
|
-
xmlStr += tagStart + ">";
|
|
191
|
-
if (tagValue && indentation !== "" && (tagValue.includes("/>") || tagValue.includes("</"))) {
|
|
192
|
-
xmlStr += indentation + options.indentBy + tagValue + indentation;
|
|
193
|
-
} else {
|
|
194
|
-
xmlStr += tagValue;
|
|
195
|
-
}
|
|
196
|
-
xmlStr += `</${tagName}>`;
|
|
197
|
-
}
|
|
198
|
-
isPreviousElementTag = true;
|
|
199
|
-
|
|
200
|
-
// Pop tag from matcher
|
|
201
|
-
matcher.pop();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return xmlStr;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Extract attribute values from the ":@" object and return as plain object
|
|
209
|
-
* for passing to matcher.push()
|
|
210
|
-
*/
|
|
211
|
-
function extractAttributeValues(attrMap, options) {
|
|
212
|
-
if (!attrMap || options.ignoreAttributes) return null;
|
|
213
|
-
|
|
214
|
-
const attrValues = {};
|
|
215
|
-
let hasAttrs = false;
|
|
216
|
-
|
|
217
|
-
for (let attr in attrMap) {
|
|
218
|
-
if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
|
|
219
|
-
// Remove the attribute prefix to get clean attribute name
|
|
220
|
-
const cleanAttrName = attr.startsWith(options.attributeNamePrefix)
|
|
221
|
-
? attr.substr(options.attributeNamePrefix.length)
|
|
222
|
-
: attr;
|
|
223
|
-
attrValues[cleanAttrName] = escapeAttribute(attrMap[attr]);
|
|
224
|
-
hasAttrs = true;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return hasAttrs ? attrValues : null;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Extract raw content from a stopNode without any processing
|
|
232
|
-
* This preserves the content exactly as-is, including special characters
|
|
233
|
-
*/
|
|
234
|
-
function getRawContent(arr, options) {
|
|
235
|
-
if (!Array.isArray(arr)) {
|
|
236
|
-
// Non-array values return as-is
|
|
237
|
-
if (arr !== undefined && arr !== null) {
|
|
238
|
-
return arr.toString();
|
|
239
|
-
}
|
|
240
|
-
return "";
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
let content = "";
|
|
244
|
-
for (let i = 0; i < arr.length; i++) {
|
|
245
|
-
const item = arr[i];
|
|
246
|
-
const tagName = propName(item);
|
|
247
|
-
|
|
248
|
-
if (tagName === options.textNodeName) {
|
|
249
|
-
// Raw text content - NO processing, NO entity replacement
|
|
250
|
-
content += item[tagName];
|
|
251
|
-
} else if (tagName === options.cdataPropName) {
|
|
252
|
-
// CDATA content
|
|
253
|
-
content += item[tagName][0][options.textNodeName];
|
|
254
|
-
} else if (tagName === options.commentPropName) {
|
|
255
|
-
// Comment content
|
|
256
|
-
content += item[tagName][0][options.textNodeName];
|
|
257
|
-
} else if (tagName && tagName[0] === "?") {
|
|
258
|
-
// Processing instruction - skip for stopNodes
|
|
259
|
-
continue;
|
|
260
|
-
} else if (tagName) {
|
|
261
|
-
// Nested tags within stopNode — no sanitizeName, content is raw
|
|
262
|
-
const attStr = attr_to_str_raw(item[":@"], options);
|
|
263
|
-
const nestedContent = getRawContent(item[tagName], options);
|
|
264
|
-
|
|
265
|
-
if (!nestedContent || nestedContent.length === 0) {
|
|
266
|
-
content += `<${tagName}${attStr}/>`;
|
|
267
|
-
} else {
|
|
268
|
-
content += `<${tagName}${attStr}>${nestedContent}</${tagName}>`;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return content;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Build attribute string for stopNodes - NO entity replacement
|
|
277
|
-
*/
|
|
278
|
-
function attr_to_str_raw(attrMap, options) {
|
|
279
|
-
let attrStr = "";
|
|
280
|
-
if (attrMap && !options.ignoreAttributes) {
|
|
281
|
-
for (let attr in attrMap) {
|
|
282
|
-
if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
|
|
283
|
-
// For stopNodes, use raw value without processing
|
|
284
|
-
let attrVal = attrMap[attr];
|
|
285
|
-
if (attrVal === true && options.suppressBooleanAttributes) {
|
|
286
|
-
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
|
|
287
|
-
} else {
|
|
288
|
-
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${escapeAttribute(attrVal)}"`;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return attrStr;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function propName(obj) {
|
|
296
|
-
const keys = Object.keys(obj);
|
|
297
|
-
for (let i = 0; i < keys.length; i++) {
|
|
298
|
-
const key = keys[i];
|
|
299
|
-
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
300
|
-
if (key !== ":@") return key;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Build attribute string, resolving attribute names through sanitizeName when configured.
|
|
306
|
-
* Accepts matcher so the callback has path context.
|
|
307
|
-
*/
|
|
308
|
-
function attr_to_str(attrMap, options, isStopNode, matcher, xmlVersion) {
|
|
309
|
-
let attrStr = "";
|
|
310
|
-
if (attrMap && !options.ignoreAttributes) {
|
|
311
|
-
for (let attr in attrMap) {
|
|
312
|
-
if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
|
|
313
|
-
|
|
314
|
-
// Strip prefix to get the clean XML attribute name, then optionally sanitize it
|
|
315
|
-
const cleanAttrName = attr.substr(options.attributeNamePrefix.length);
|
|
316
|
-
const resolvedAttrName = isStopNode
|
|
317
|
-
? cleanAttrName // stopNodes are raw — skip sanitizeName for attr names too
|
|
318
|
-
: resolveTagName(cleanAttrName, true, options, matcher, xmlVersion);
|
|
319
|
-
|
|
320
|
-
let attrVal;
|
|
321
|
-
if (isStopNode) {
|
|
322
|
-
// For stopNodes, use raw value without any processing
|
|
323
|
-
attrVal = attrMap[attr];
|
|
324
|
-
} else {
|
|
325
|
-
// Normal processing: apply attributeValueProcessor and entity replacement
|
|
326
|
-
attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
|
|
327
|
-
attrVal = replaceEntitiesValue(attrVal, options);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (attrVal === true && options.suppressBooleanAttributes) {
|
|
331
|
-
attrStr += ` ${resolvedAttrName}`;
|
|
332
|
-
} else {
|
|
333
|
-
attrStr += ` ${resolvedAttrName}="${escapeAttribute(attrVal)}"`;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
return attrStr;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
function checkStopNode(matcher, stopNodeExpressions) {
|
|
341
|
-
if (!stopNodeExpressions || stopNodeExpressions.length === 0) return false;
|
|
342
|
-
|
|
343
|
-
for (let i = 0; i < stopNodeExpressions.length; i++) {
|
|
344
|
-
if (matcher.matches(stopNodeExpressions[i])) {
|
|
345
|
-
return true;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
return false;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
function replaceEntitiesValue(textValue, options) {
|
|
352
|
-
if (textValue && textValue.length > 0 && options.processEntities) {
|
|
353
|
-
for (let i = 0; i < options.entities.length; i++) {
|
|
354
|
-
const entity = options.entities[i];
|
|
355
|
-
textValue = textValue.replace(entity.regex, entity.val);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return textValue;
|
|
359
|
-
}
|
|
File without changes
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function safeComment(val) {
|
|
4
|
-
return String(val)
|
|
5
|
-
.replace(/--/g, '- -') // -- is illegal anywhere in comment content
|
|
6
|
-
.replace(/--/g, '- -') // handle the scenario when 2 consiucative dashes appears
|
|
7
|
-
.replace(/-$/, '- '); // trailing - would form -- with the closing -->
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function safeCdata(val) {
|
|
11
|
-
return String(val).replace(/\]\]>/g, ']]]]><![CDATA[>')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function escapeAttribute(val) {
|
|
15
|
-
return String(val).replace(/"/g, '"').replace(/'/g, ''')
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|