mirror of
https://github.com/actions/setup-java.git
synced 2026-11-14 13:10:34 +08:00
chore(deps): bump fast-xml-parser from 5.11.2 to 5.12.0 (#1323)
* chore(deps): bump fast-xml-parser from 5.11.2 to 5.12.0 Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.11.2 to 5.12.0. - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.11.2...v5.12.0) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.12.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Fix generated dist and license records Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bruno Borges <brborges@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot App
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bruno Borges
parent
9ce5b12cb9
commit
a3c8068301
Vendored
+27
-14
@@ -15686,19 +15686,26 @@ var Matcher = __webpack_require__(8257);
|
||||
;// CONCATENATED MODULE: ./node_modules/fast-xml-builder/src/util.js
|
||||
|
||||
|
||||
// String(val)/val.toString() drop the sign of -0 (e.g. String(-0) === '0'), silently
|
||||
// corrupting a round-tripped negative-zero value. XML has no separate int/float syntax,
|
||||
// so this is the single place every raw value gets turned into text.
|
||||
function valToStr(val) {
|
||||
return typeof val === 'number' && Object.is(val, -0) ? '-0' : String(val)
|
||||
}
|
||||
|
||||
function safeComment(val) {
|
||||
return String(val)
|
||||
return valToStr(val)
|
||||
.replace(/--/g, '- -') // -- is illegal anywhere in comment content
|
||||
.replace(/--/g, '- -') // handle the scenario when 2 consiucative dashes appears
|
||||
.replace(/-$/, '- '); // trailing - would form -- with the closing -->
|
||||
}
|
||||
|
||||
function safeCdata(val) {
|
||||
return String(val).replace(/\]\]>/g, ']]]]><![CDATA[>')
|
||||
return valToStr(val).replace(/\]\]>/g, ']]]]><![CDATA[>')
|
||||
}
|
||||
|
||||
function escapeAttribute(val) {
|
||||
return String(val).replace(/"/g, '"').replace(/'/g, ''')
|
||||
return valToStr(val).replace(/"/g, '"').replace(/'/g, ''')
|
||||
}
|
||||
// EXTERNAL MODULE: ./node_modules/xml-naming/src/index.js
|
||||
var src = __webpack_require__(4658);
|
||||
@@ -15793,7 +15800,7 @@ function arrToStr(arr, options, indentation, matcher, stopNodeExpressions, qName
|
||||
if (!Array.isArray(arr)) {
|
||||
// Non-array values (e.g. string tag values) should be treated as text content
|
||||
if (arr !== undefined && arr !== null) {
|
||||
let text = arr.toString();
|
||||
let text = valToStr(arr);
|
||||
text = replaceEntitiesValue(text, options);
|
||||
return text;
|
||||
}
|
||||
@@ -15832,6 +15839,7 @@ function arrToStr(arr, options, indentation, matcher, stopNodeExpressions, qName
|
||||
tagText = options.tagValueProcessor(tagName, tagText);
|
||||
tagText = replaceEntitiesValue(tagText, options);
|
||||
}
|
||||
tagText = valToStr(tagText);
|
||||
if (isPreviousElementTag) {
|
||||
xmlStr += indentation;
|
||||
}
|
||||
@@ -15940,7 +15948,7 @@ function orderedJs2Xml_getRawContent(arr, options) {
|
||||
if (!Array.isArray(arr)) {
|
||||
// Non-array values return as-is
|
||||
if (arr !== undefined && arr !== null) {
|
||||
return arr.toString();
|
||||
return valToStr(arr);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -15952,7 +15960,7 @@ function orderedJs2Xml_getRawContent(arr, options) {
|
||||
|
||||
if (tagName === options.textNodeName) {
|
||||
// Raw text content - NO processing, NO entity replacement
|
||||
content += item[tagName];
|
||||
content += valToStr(item[tagName]);
|
||||
} else if (tagName === options.cdataPropName) {
|
||||
// CDATA content
|
||||
content += item[tagName][0][options.textNodeName];
|
||||
@@ -16293,11 +16301,11 @@ Builder.prototype.j2x = function (jObj, level, matcher, qNameValidator) {
|
||||
if (attr && !this.ignoreAttributesFn(attr, jPath)) {
|
||||
// Resolve the attribute name through sanitizeName
|
||||
const resolvedAttr = fxb_resolveTagName(attr, true, this.options, matcher, qNameValidator);
|
||||
attrStr += this.buildAttrPairStr(resolvedAttr, '' + jObj[key], isCurrentStopNode);
|
||||
attrStr += this.buildAttrPairStr(resolvedAttr, valToStr(jObj[key]), isCurrentStopNode);
|
||||
} else if (!attr) {
|
||||
//tag value
|
||||
if (key === this.options.textNodeName) {
|
||||
let newval = this.options.tagValueProcessor(key, '' + jObj[key]);
|
||||
let newval = this.options.tagValueProcessor(key, valToStr(jObj[key]));
|
||||
val += this.replaceEntitiesValue(newval);
|
||||
} else {
|
||||
// Check if this is a stopNode before building
|
||||
@@ -16307,7 +16315,7 @@ Builder.prototype.j2x = function (jObj, level, matcher, qNameValidator) {
|
||||
|
||||
if (isStopNode) {
|
||||
// Build as raw content without encoding
|
||||
const textValue = '' + jObj[key];
|
||||
const textValue = valToStr(jObj[key]);
|
||||
if (textValue === '') {
|
||||
val += this.indentate(level) + '<' + resolvedKey + this.closeTag(resolvedKey) + this.tagEndChar;
|
||||
} else {
|
||||
@@ -16349,6 +16357,7 @@ Builder.prototype.j2x = function (jObj, level, matcher, qNameValidator) {
|
||||
if (this.options.oneListGroup) {
|
||||
let textValue = this.options.tagValueProcessor(resolvedKey, item);
|
||||
textValue = this.replaceEntitiesValue(textValue);
|
||||
textValue = valToStr(textValue);
|
||||
listTagVal += textValue;
|
||||
} else {
|
||||
// Check if this is a stopNode before building
|
||||
@@ -16358,7 +16367,7 @@ Builder.prototype.j2x = function (jObj, level, matcher, qNameValidator) {
|
||||
|
||||
if (isStopNode) {
|
||||
// Build as raw content without encoding
|
||||
const textValue = '' + item;
|
||||
const textValue = valToStr(item);
|
||||
if (textValue === '') {
|
||||
listTagVal += this.indentate(level) + '<' + resolvedKey + this.closeTag(resolvedKey) + this.tagEndChar;
|
||||
} else {
|
||||
@@ -16382,7 +16391,7 @@ Builder.prototype.j2x = function (jObj, level, matcher, qNameValidator) {
|
||||
for (let j = 0; j < L; j++) {
|
||||
// Resolve attribute names inside attributesGroupName
|
||||
const resolvedAttr = fxb_resolveTagName(Ks[j], true, this.options, matcher, qNameValidator);
|
||||
attrStr += this.buildAttrPairStr(resolvedAttr, '' + jObj[key][Ks[j]], isCurrentStopNode);
|
||||
attrStr += this.buildAttrPairStr(resolvedAttr, valToStr(jObj[key][Ks[j]]), isCurrentStopNode);
|
||||
}
|
||||
} else {
|
||||
val += this.processTextOrObjNode(jObj[key], resolvedKey, level, matcher, qNameValidator)
|
||||
@@ -16394,7 +16403,7 @@ Builder.prototype.j2x = function (jObj, level, matcher, qNameValidator) {
|
||||
|
||||
Builder.prototype.buildAttrPairStr = function (attrName, val, isStopNode) {
|
||||
if (!isStopNode) {
|
||||
val = this.options.attributeValueProcessor(attrName, '' + val);
|
||||
val = this.options.attributeValueProcessor(attrName, valToStr(val));
|
||||
val = this.replaceEntitiesValue(val);
|
||||
}
|
||||
if (this.options.suppressBooleanAttributes && val === "true") {
|
||||
@@ -16654,6 +16663,10 @@ Builder.prototype.buildTextValNode = function (val, key, attrStr, level, matcher
|
||||
// Normal processing: apply tagValueProcessor and entity replacement
|
||||
let textValue = this.options.tagValueProcessor(key, val);
|
||||
textValue = this.replaceEntitiesValue(textValue);
|
||||
// tagValueProcessor may return the raw value unchanged (default is identity), and
|
||||
// replaceEntitiesValue no-ops on non-strings, so a plain number can still reach here;
|
||||
// stringify it now, sign-preserving, before it's implicitly ToString'd below.
|
||||
textValue = valToStr(textValue);
|
||||
|
||||
if (textValue === '') {
|
||||
return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;
|
||||
@@ -16695,8 +16708,8 @@ function isAttribute(name /*, options*/) {
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/fast-xml-parser/src/fxp.js
|
||||
var fxp = __webpack_require__(5824);
|
||||
// EXTERNAL MODULE: ./node_modules/fast-xml-parser/src/xmlparser/XMLParser.js + 22 modules
|
||||
var XMLParser = __webpack_require__(6009);
|
||||
// EXTERNAL MODULE: ./node_modules/fast-xml-parser/src/xmlparser/XMLParser.js + 23 modules
|
||||
var XMLParser = __webpack_require__(1143);
|
||||
;// CONCATENATED MODULE: ./node_modules/@azure/core-xml/dist/esm/xml.common.js
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
Vendored
+140
-24
@@ -10,7 +10,7 @@ export const modules = {
|
||||
/* harmony export */ i: () => (/* binding */ XMLValidator)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _validator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1176);
|
||||
/* harmony import */ var _xmlparser_XMLParser_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6009);
|
||||
/* harmony import */ var _xmlparser_XMLParser_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1143);
|
||||
|
||||
|
||||
|
||||
@@ -627,7 +627,7 @@ function getPositionFromMatch(match) {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 6009:
|
||||
/***/ 1143:
|
||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
|
||||
@@ -1582,8 +1582,10 @@ function toNumber(str, options = {}) {
|
||||
return parse_int(trimmedStr, 2);
|
||||
} else if (options.octal && octRegex.test(trimmedStr)) {
|
||||
return parse_int(trimmedStr, 8);
|
||||
} else if (!isFinite(trimmedStr)) { //Infinity
|
||||
return handleInfinity(str, Number(trimmedStr), options);
|
||||
} else if (!isFinite(trimmedStr)) { //Infinity or not a number
|
||||
const num = Number(trimmedStr);
|
||||
if (Number.isNaN(num)) return str; //not a number: always the original string
|
||||
return handleInfinity(str, num, options); //only +/-Infinity reaches here
|
||||
} else if (trimmedStr.includes('e') || trimmedStr.includes('E')) { //eNotation
|
||||
return resolveEnotation(str, trimmedStr, options);
|
||||
} else {
|
||||
@@ -1595,8 +1597,8 @@ function toNumber(str, options = {}) {
|
||||
const leadingZeros = match[2];
|
||||
let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros
|
||||
const decimalAdjacentToLeadingZeros = sign ? // 0., -00., 000.
|
||||
str[leadingZeros.length + 1] === "."
|
||||
: str[leadingZeros.length] === ".";
|
||||
trimmedStr[leadingZeros.length + 1] === "."
|
||||
: trimmedStr[leadingZeros.length] === ".";
|
||||
|
||||
//trim ending zeros for floating number
|
||||
if (!options.leadingZeros //leading zeros are not allowed
|
||||
@@ -1644,8 +1646,8 @@ function resolveEnotation(str, trimmedStr, options) {
|
||||
const eChar = notation[3].indexOf("e") === -1 ? "E" : "e";
|
||||
const leadingZeros = notation[2];
|
||||
const eAdjacentToLeadingZeros = sign ? // 0E.
|
||||
str[leadingZeros.length + 1] === eChar
|
||||
: str[leadingZeros.length] === eChar;
|
||||
trimmedStr[leadingZeros.length + 1] === eChar
|
||||
: trimmedStr[leadingZeros.length] === eChar;
|
||||
|
||||
if (leadingZeros.length > 1 && eAdjacentToLeadingZeros) return str;
|
||||
else if (leadingZeros.length === 1
|
||||
@@ -1654,8 +1656,7 @@ function resolveEnotation(str, trimmedStr, options) {
|
||||
} else if (leadingZeros.length > 0) {
|
||||
// Has leading zeros — only accept if leadingZeros option allows it
|
||||
if (options.leadingZeros && !eAdjacentToLeadingZeros) {
|
||||
trimmedStr = (notation[1] || "") + notation[3];
|
||||
return Number(trimmedStr);
|
||||
return Number(trimmedStr); // Number() accepts leading zeros; stripping can leave a mantissa-less ".e0"
|
||||
} else return str;
|
||||
} else {
|
||||
// No leading zeros — always valid e-notation, parse it
|
||||
@@ -1718,6 +1719,7 @@ function handleInfinity(str, num, options) {
|
||||
return str; // Return original string like "1e1000"
|
||||
}
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/fast-xml-parser/src/ignoreAttributes.js
|
||||
function getIgnoreAttributesFn(ignoreAttributes) {
|
||||
if (typeof ignoreAttributes === 'function') {
|
||||
@@ -3899,6 +3901,56 @@ const SQL_STRICT_PATTERNS = [...sql, ...SQL_STRICT_EXTRA];
|
||||
|
||||
/* harmony default export */ const sql_strict = (SQL_STRICT_PATTERNS);
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/is-unsafe/src/util/decode-entities.js
|
||||
/**
|
||||
* Decode the HTML character references that matter for markup-context
|
||||
* detection.
|
||||
*
|
||||
* Browsers decode character references in attribute values before they
|
||||
* interpret a URL, so `javascript:alert(1)` in an href is the
|
||||
* `javascript:` scheme. The HTML/XML/SVG rules match literal characters, so
|
||||
* without this step such payloads slip through.
|
||||
*
|
||||
* Deliberately NOT a full entity decoder. It decodes only:
|
||||
* - decimal refs : : : : (any leading zeros,
|
||||
* trailing ; optional — browsers accept both)
|
||||
* - hex refs : : : : (same)
|
||||
* - named refs : 	 

|
||||
* Named refs are CASE-SENSITIVE and REQUIRE the trailing ';', exactly
|
||||
* like a browser (so `&COLON;` and `&colon` are not decoded).
|
||||
* 	 / 
 matter because the URL parser strips tab/newline,
|
||||
* so `java	script:` is still a javascript: URL.
|
||||
*
|
||||
* It does NOT decode & (single pass only), so double-encoded text such as
|
||||
* "&lt;script&gt;" stays literal — a browser renders that as text.
|
||||
*
|
||||
* All quantifiers are bounded; no ReDoS risk.
|
||||
*
|
||||
* @param {string} input
|
||||
* @returns {string}
|
||||
*/
|
||||
const NAMED = Object.freeze({
|
||||
colon: ':',
|
||||
Tab: '\t',
|
||||
NewLine: '\n',
|
||||
});
|
||||
|
||||
const ENTITY_RE =
|
||||
/&(?:#[xX]0*([0-9a-fA-F]{1,6});?|#0*([0-9]{1,7});?|([a-zA-Z][a-zA-Z0-9]{1,15});)/g;
|
||||
|
||||
function decodeEntities(input) {
|
||||
if (input.indexOf('&') === -1) return input;
|
||||
|
||||
return input.replace(ENTITY_RE, (match, hex, dec, name) => {
|
||||
if (name !== undefined) {
|
||||
return Object.prototype.hasOwnProperty.call(NAMED, name) ? NAMED[name] : match;
|
||||
}
|
||||
const cp = hex !== undefined ? parseInt(hex, 16) : parseInt(dec, 10);
|
||||
if (!Number.isFinite(cp) || cp > 0x10ffff) return match;
|
||||
return String.fromCodePoint(cp);
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./node_modules/is-unsafe/src/contexts/html.js
|
||||
/**
|
||||
* HTML context patterns.
|
||||
@@ -4062,7 +4114,8 @@ const XML_PATTERNS = [
|
||||
{
|
||||
id: 'xml-namespace-confusion',
|
||||
description: 'xmlns: attribute injection — can redefine namespaces to confuse parsers',
|
||||
pattern: /\bxmlns\s*(?::\w{1,40})?\s*=/i,
|
||||
// pattern: /\bxmlns\s*(?::\w{1,40})?\s*=/i,
|
||||
pattern: /\bxmlns(?::\w{1,40})?\s*=/i,
|
||||
},
|
||||
{
|
||||
id: 'xml-comment-injection',
|
||||
@@ -4581,6 +4634,11 @@ const LOG_PATTERNS = [
|
||||
|
||||
|
||||
|
||||
// Markup contexts are also matched against an entity-decoded copy of the input,
|
||||
// because browsers decode HTML character references before interpreting a URL
|
||||
// scheme (e.g. javascript:… is a javascript: URL).
|
||||
|
||||
|
||||
// ─── VALID_CONTEXTS convenience re-export ─────────────────────────────────
|
||||
// Importing this pulls in ALL contexts. Use it only when you need all of them
|
||||
// (e.g. for validation UI, tooling, or exhaustive audits).
|
||||
@@ -4603,6 +4661,12 @@ const LOG_PATTERNS = [
|
||||
html.label = 'HTML';
|
||||
xml.label = 'XML';
|
||||
svg.label = 'SVG';
|
||||
|
||||
// Markup contexts: also test an entity-decoded copy (see util/decode-entities.js).
|
||||
// Non-markup contexts (SQL, SHELL, LOG, …) are matched byte-for-byte as supplied.
|
||||
html.decodeEntities = true;
|
||||
xml.decodeEntities = true;
|
||||
svg.decodeEntities = true;
|
||||
sql.label = 'SQL';
|
||||
sql_strict.label = 'SQL-STRICT';
|
||||
shell.label = 'SHELL';
|
||||
@@ -4697,6 +4761,20 @@ function normalise(context) {
|
||||
return { lists: [context], regex: null };
|
||||
}
|
||||
|
||||
/**
|
||||
* For markup contexts, return an entity-decoded copy of `value` to test
|
||||
* alongside the raw input, or null when there is nothing extra to test.
|
||||
*
|
||||
* @param {string} value
|
||||
* @param {Rule[]} list
|
||||
* @returns {string|null}
|
||||
*/
|
||||
function decodedCopy(value, list) {
|
||||
if (!list.decodeEntities) return null;
|
||||
const decoded = decodeEntities(value);
|
||||
return decoded === value ? null : decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test value against a single PatternList. Returns the first MatchResult or null.
|
||||
*
|
||||
@@ -4706,8 +4784,9 @@ function normalise(context) {
|
||||
*/
|
||||
function matchList(value, list) {
|
||||
const label = list.label ?? 'CUSTOM';
|
||||
const decoded = decodedCopy(value, list);
|
||||
for (const rule of list) {
|
||||
if (rule.pattern.test(value)) {
|
||||
if (rule.pattern.test(value) || (decoded !== null && rule.pattern.test(decoded))) {
|
||||
return { context: label, id: rule.id, description: rule.description, pattern: rule.pattern };
|
||||
}
|
||||
}
|
||||
@@ -4805,8 +4884,9 @@ function allUnsafe(value, context) {
|
||||
|
||||
for (const list of lists) {
|
||||
const label = list.label ?? 'CUSTOM';
|
||||
const decoded = decodedCopy(value, list);
|
||||
for (const rule of list) {
|
||||
if (rule.pattern.test(value)) {
|
||||
if (rule.pattern.test(value) || (decoded !== null && rule.pattern.test(decoded))) {
|
||||
results.push({ context: label, id: rule.id, description: rule.description, pattern: rule.pattern });
|
||||
}
|
||||
}
|
||||
@@ -5104,7 +5184,15 @@ function buildAttributesMap(attrStr, jPath, tagName, force = false) {
|
||||
}
|
||||
}
|
||||
const parseXml = function (xmlData) {
|
||||
xmlData = xmlData.replace(/\r\n?/g, "\n"); //TODO: remove this line
|
||||
const options = this.options;
|
||||
const crlfPositions = options.captureMetaData ? [] : undefined;
|
||||
xmlData = xmlData.replace(/\r\n?/g, options.captureMetaData ? (newline, index) => {
|
||||
if (newline.length === 2) {
|
||||
// Store the position after earlier CRLF pairs have been normalized.
|
||||
crlfPositions.push(index - crlfPositions.length);
|
||||
}
|
||||
return "\n";
|
||||
} : "\n");
|
||||
const xmlObj = new XmlNode('!xml');
|
||||
let currentNode = xmlObj;
|
||||
let textData = "";
|
||||
@@ -5117,7 +5205,6 @@ const parseXml = function (xmlData) {
|
||||
this.entityExpansionCount = 0;
|
||||
this.currentExpandedLength = 0;
|
||||
this.doctypefound = false;
|
||||
const options = this.options;
|
||||
const docTypeReader = new DocTypeReader(options.processEntities);
|
||||
const xmlLen = xmlData.length;
|
||||
for (let i = 0; i < xmlLen; i++) {//for each char in XML data
|
||||
@@ -5161,7 +5248,7 @@ const parseXml = function (xmlData) {
|
||||
currentNode = this.tagsNodeStack.pop() || xmlObj;//avoid recursion, set the parent tag scope
|
||||
|
||||
if (options.captureMetaData && currentNode) {
|
||||
currentNode.addEndIndex(closeIndex + 1);
|
||||
currentNode.addEndIndex(getOriginalIndex(closeIndex + 1, crlfPositions));
|
||||
}
|
||||
textData = "";
|
||||
i = closeIndex;
|
||||
@@ -5187,11 +5274,12 @@ const parseXml = function (xmlData) {
|
||||
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent && options.ignoreAttributes !== true) {
|
||||
childNode[":@"] = attsMap
|
||||
}
|
||||
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
||||
const startIndex = options.captureMetaData ? getOriginalIndex(i, crlfPositions) : i;
|
||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||
|
||||
if (options.captureMetaData) {
|
||||
// closeIndex points at '?' of the closing '?>'
|
||||
currentNode.addEndIndex(tagData.closeIndex + 2);
|
||||
currentNode.addEndIndex(getOriginalIndex(tagData.closeIndex + 2, crlfPositions));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5323,7 +5411,7 @@ const parseXml = function (xmlData) {
|
||||
this.isCurrentNodeStopNode = this.isItStopNode();
|
||||
}
|
||||
|
||||
const startIndex = i;
|
||||
const startIndex = options.captureMetaData ? getOriginalIndex(i, crlfPositions) : i;
|
||||
if (this.isCurrentNodeStopNode) {
|
||||
let tagContent = "";
|
||||
|
||||
@@ -5359,7 +5447,7 @@ const parseXml = function (xmlData) {
|
||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||
|
||||
if (options.captureMetaData) {
|
||||
currentNode.addEndIndex(i + 1);
|
||||
currentNode.addEndIndex(getOriginalIndex(i + 1, crlfPositions));
|
||||
}
|
||||
} else {
|
||||
//selfClosing tag
|
||||
@@ -5373,7 +5461,7 @@ const parseXml = function (xmlData) {
|
||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||
|
||||
if (options.captureMetaData) {
|
||||
currentNode.addEndIndex(closeIndex + 1);
|
||||
currentNode.addEndIndex(getOriginalIndex(closeIndex + 1, crlfPositions));
|
||||
}
|
||||
this.matcher.pop(); // Pop self-closing tag
|
||||
this.isCurrentNodeStopNode = false; // Reset flag
|
||||
@@ -5386,7 +5474,7 @@ const parseXml = function (xmlData) {
|
||||
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
||||
|
||||
if (options.captureMetaData) {
|
||||
currentNode.addEndIndex(result.closeIndex + 1);
|
||||
currentNode.addEndIndex(getOriginalIndex(result.closeIndex + 1, crlfPositions));
|
||||
}
|
||||
this.matcher.pop(); // Pop unpaired tag
|
||||
this.isCurrentNodeStopNode = false; // Reset flag
|
||||
@@ -5419,6 +5507,17 @@ const parseXml = function (xmlData) {
|
||||
return xmlObj.child;
|
||||
}
|
||||
|
||||
function getOriginalIndex(index, crlfPositions) {
|
||||
let low = 0;
|
||||
let high = crlfPositions.length;
|
||||
while (low < high) {
|
||||
const middle = Math.floor((low + high) / 2);
|
||||
if (crlfPositions[middle] < index) low = middle + 1;
|
||||
else high = middle;
|
||||
}
|
||||
return index + low;
|
||||
}
|
||||
|
||||
function addChild(currentNode, childNode, matcher, startIndex) {
|
||||
// unset startIndex if not requested
|
||||
if (!this.options.captureMetaData) startIndex = undefined;
|
||||
@@ -5597,6 +5696,8 @@ function readStopNodeData(xmlData, tagName, i) {
|
||||
const startIndex = i;
|
||||
// Starting at 1 since we already have an open tag
|
||||
let openTagCount = 1;
|
||||
let lenient = false; // set once a quote-aware tag scan fails
|
||||
let nextGt = -1; // cached index of the next '>'
|
||||
|
||||
const xmllen = xmlData.length;
|
||||
for (; i < xmllen; i++) {
|
||||
@@ -5628,14 +5729,29 @@ function readStopNodeData(xmlData, tagName, i) {
|
||||
const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
|
||||
i = closeIndex;
|
||||
} else {
|
||||
const tagData = readTagExp(xmlData, i, false)
|
||||
const tagData = lenient ? undefined : readTagExp(xmlData, i, false);
|
||||
|
||||
if (tagData) {
|
||||
const openTagName = tagData && tagData.tagName;
|
||||
const openTagName = tagData.tagName;
|
||||
if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
|
||||
openTagCount++;
|
||||
}
|
||||
i = tagData.closeIndex;
|
||||
} else {
|
||||
// no closing '>'. use lenient approach to find '<' instead of readTagExp, to avoid repeated rescans.
|
||||
lenient = true;
|
||||
if (nextGt < i) {
|
||||
nextGt = xmlData.indexOf(">", i);
|
||||
if (nextGt === -1) return; // no '>' left, so no closing tag can follow
|
||||
}
|
||||
const nextLt = xmlData.indexOf("<", i + 1);
|
||||
if (nextLt === -1 || nextLt > nextGt) { // looks like a real tag
|
||||
const exp = xmlData.substring(i + 1, nextGt);
|
||||
const sep = exp.search(/\s/);
|
||||
const name = sep === -1 ? exp : exp.substring(0, sep);
|
||||
if (name === tagName && exp[exp.length - 1] !== "/") openTagCount++;
|
||||
i = nextGt;
|
||||
} // else: treat this '<' as plain text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user