diff --git a/.github/workflows/post-release-mergeback.yml b/.github/workflows/post-release-mergeback.yml index 95e66ecd79..1a85cfd197 100644 --- a/.github/workflows/post-release-mergeback.yml +++ b/.github/workflows/post-release-mergeback.yml @@ -131,7 +131,7 @@ jobs: echo "::endgroup::" - name: Generate token - uses: actions/create-github-app-token@v2.2.1 + uses: actions/create-github-app-token@v3.0.0 id: app-token with: app-id: ${{ vars.AUTOMATION_APP_ID }} diff --git a/.github/workflows/rollback-release.yml b/.github/workflows/rollback-release.yml index 4b5b68cf36..f309b13a96 100644 --- a/.github/workflows/rollback-release.yml +++ b/.github/workflows/rollback-release.yml @@ -136,7 +136,7 @@ jobs: - name: Generate token if: github.event_name == 'workflow_dispatch' - uses: actions/create-github-app-token@v2.2.1 + uses: actions/create-github-app-token@v3.0.0 id: app-token with: app-id: ${{ vars.AUTOMATION_APP_ID }} diff --git a/.github/workflows/update-release-branch.yml b/.github/workflows/update-release-branch.yml index bd38d922e4..5465396664 100644 --- a/.github/workflows/update-release-branch.yml +++ b/.github/workflows/update-release-branch.yml @@ -93,7 +93,7 @@ jobs: pull-requests: write # needed to create pull request steps: - name: Generate token - uses: actions/create-github-app-token@v2.2.1 + uses: actions/create-github-app-token@v3.0.0 id: app-token with: app-id: ${{ vars.AUTOMATION_APP_ID }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c8ca27f718..3999095366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs. +## 3.34.0 - 20 Mar 2026 + +- Added an experimental change which disables TRAP caching when [improved incremental analysis](https://github.com/github/roadmap/issues/1158) is enabled, since improved incremental analysis supersedes TRAP caching. This will improve performance and reduce Actions cache usage. We expect to roll this change out to everyone in March. [#3569](https://github.com/github/codeql-action/pull/3569) +- We are rolling out improved incremental analysis to C/C++ analyses that use build mode `none`. We expect this rollout to be complete by the end of April 2026. [#3584](https://github.com/github/codeql-action/pull/3584) +- Update default CodeQL bundle version to [2.25.0](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.0). [#3585](https://github.com/github/codeql-action/pull/3585) + ## 3.33.0 - 16 Mar 2026 - Upcoming change: Starting April 2026, the CodeQL Action will skip collecting file coverage information on pull requests to improve analysis performance. File coverage information will still be computed on non-PR analyses. Pull request analyses will log a warning about this upcoming change. [#3562](https://github.com/github/codeql-action/pull/3562) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index ec89e511e9..c4d49534cf 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable6; + exports2.exportVariable = exportVariable7; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable6(name, val) { + function exportVariable7(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -48640,7 +48640,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -48652,23 +48652,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core14.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core15.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core14.debug(`implicitDescendants '${result.implicitDescendants}'`); + core15.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core14.debug(`matchDirectories '${result.matchDirectories}'`); + core15.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core14.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core15.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core14.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core15.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -50296,7 +50296,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs8 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path7 = __importStar2(require("path")); @@ -50349,7 +50349,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core14.debug(`Search path '${searchPath}'`); + core15.debug(`Search path '${searchPath}'`); try { yield __await2(fs8.promises.lstat(searchPath)); } catch (err) { @@ -50424,7 +50424,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core14.debug(`Broken symlink '${item.path}'`); + core15.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -50440,7 +50440,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core14.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core15.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -50543,7 +50543,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles2; var crypto2 = __importStar2(require("crypto")); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs8 = __importStar2(require("fs")); var stream = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -50552,7 +50552,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core14.info : core14.debug; + const writeDelegate = verbose ? core15.info : core15.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -51943,7 +51943,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var exec3 = __importStar2(require_exec()); var glob2 = __importStar2(require_glob()); var io6 = __importStar2(require_io()); @@ -51994,7 +51994,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path7.relative(workspace, file).replace(new RegExp(`\\${path7.sep}`, "g"), "/"); - core14.debug(`Matched: ${relativeFile}`); + core15.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -52022,7 +52022,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core14.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core15.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec3.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -52033,10 +52033,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core14.debug(err.message); + core15.debug(err.message); } versionOutput = versionOutput.trim(); - core14.debug(versionOutput); + core15.debug(versionOutput); return versionOutput; }); } @@ -52044,7 +52044,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core14.debug(`zstd version: ${version}`); + core15.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -61827,44 +61827,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -61872,63 +61872,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61937,16 +61937,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61955,83 +61955,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62045,190 +62052,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _2(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _2(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _2(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _2(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _2 = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _2), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -62238,290 +62454,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + } + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - function H(t2, e2, n2) { - let i2; + function lt(t2, e2, i2) { + return pt(t2, e2, i2); + } + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62530,172 +62781,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } } - return s2; + return i2; } - function ot(t2) { + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + } + return i2; + } + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -91700,7 +92084,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -91742,7 +92126,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core15.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91799,14 +92183,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core14.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core15.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core14.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core15.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -91891,7 +92275,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -91949,9 +92333,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core14.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core15.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core14.debug(`${name} - Error is not retryable`); + core15.debug(`${name} - Error is not retryable`); break; } yield sleep(delay); @@ -92210,7 +92594,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -92248,7 +92632,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core14.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core15.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -92282,7 +92666,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core15.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -92332,7 +92716,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core14.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core15.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -92343,7 +92727,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core14.debug("Unable to validate download, no Content-Length header"); + core15.debug("Unable to validate download, no Content-Length header"); } }); } @@ -92461,7 +92845,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core14.debug("Unable to determine content length, downloading file with http-client..."); + core15.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -92551,7 +92935,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -92571,9 +92955,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core14.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core15.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -92609,12 +92993,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Download concurrency: ${result.downloadConcurrency}`); - core14.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core14.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core14.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core14.debug(`Lookup only: ${result.lookupOnly}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Download concurrency: ${result.downloadConcurrency}`); + core15.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core15.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core15.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core15.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -92808,7 +93192,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache5; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs8 = __importStar2(require("fs")); @@ -92826,7 +93210,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url = `${baseUrl}_apis/artifactcache/${resource}`; - core14.debug(`Resource Url: ${url}`); + core15.debug(`Resource Url: ${url}`); return url; } function createAcceptHeader(type2, apiVersion) { @@ -92854,7 +93238,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core14.isDebug()) { + if (core15.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -92867,9 +93251,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core14.setSecret(cacheDownloadUrl); - core14.debug(`Cache Result:`); - core14.debug(JSON.stringify(cacheResult)); + core15.setSecret(cacheDownloadUrl); + core15.debug(`Cache Result:`); + core15.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -92883,10 +93267,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core14.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core15.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core14.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core15.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -92929,7 +93313,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core14.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core15.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -92951,7 +93335,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core14.debug("Awaiting all uploads"); + core15.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -92994,16 +93378,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core14.debug("Upload cache"); + core15.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core14.debug("Commiting cache"); + core15.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core15.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core14.info("Cache saved successfully"); + core15.info("Cache saved successfully"); } }); } @@ -98486,7 +98870,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache5; exports2.saveCache = saveCache5; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var path7 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -98545,7 +98929,7 @@ var require_cache5 = __commonJS({ function restoreCache5(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -98560,8 +98944,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98579,19 +98963,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path7.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -98599,16 +98983,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98619,8 +99003,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98638,30 +99022,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core14.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core15.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core14.info(`Cache hit for restore-key: ${response.matchedKey}`); + core15.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core14.info(`Cache hit for: ${response.matchedKey}`); + core15.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path7.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive path: ${archivePath}`); - core14.debug(`Starting download of archive to: ${archivePath}`); + core15.debug(`Archive path: ${archivePath}`); + core15.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core14.isDebug()) { + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -98669,9 +99053,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -98680,7 +99064,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98689,7 +99073,7 @@ var require_cache5 = __commonJS({ function saveCache5(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -98707,26 +99091,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path7.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -98739,26 +99123,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core14.debug(`Saving Cache (ID: ${cacheId})`); + core15.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -98771,23 +99155,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path7.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -98798,16 +99182,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core14.warning(`Cache reservation failed: ${response.message}`); + core15.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core14.debug(`Failed to reserve cache: ${error3}`); + core15.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core14.debug(`Attempting to upload cache located at: ${archivePath}`); + core15.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -98815,7 +99199,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core14.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core15.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -98828,21 +99212,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core14.warning(typedError.message); + core15.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99069,7 +99453,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99092,10 +99476,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core14.info(err.message); + core15.info(err.message); } const seconds = this.getSleepAmount(); - core14.info(`Waiting ${seconds} seconds before trying again`); + core15.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99198,7 +99582,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var io6 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs8 = __importStar2(require("fs")); @@ -99227,8 +99611,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path7.join(_getTempDirectory(), crypto2.randomUUID()); yield io6.mkdirP(path7.dirname(dest)); - core14.debug(`Downloading ${url}`); - core14.debug(`Destination ${dest}`); + core15.debug(`Downloading ${url}`); + core15.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99254,7 +99638,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99263,7 +99647,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { const err = new HTTPError(response.message.statusCode); - core14.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core15.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream.pipeline); @@ -99272,16 +99656,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs8.createWriteStream(dest)); - core14.debug("download complete"); + core15.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core14.debug("download failed"); + core15.debug("download failed"); try { yield io6.rmRF(dest); } catch (err) { - core14.debug(`Failed to delete '${dest}'. ${err.message}`); + core15.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99296,7 +99680,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core14.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core15.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core14.debug("Checking tar --version"); + core15.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99359,7 +99743,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core14.debug(versionOutput.trim()); + core15.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99367,7 +99751,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core14.isDebug() && !flags.includes("v")) { + if (core15.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99398,7 +99782,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core14.isDebug()) { + if (core15.isDebug()) { args.push("-v"); } const xarPath = yield io6.which("xar", true); @@ -99441,7 +99825,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core14.debug(`Using pwsh at path: ${pwshPath}`); + core15.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99461,7 +99845,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io6.which("powershell", true); - core14.debug(`Using powershell at path: ${powershellPath}`); + core15.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99470,7 +99854,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io6.which("unzip", true); const args = [file]; - if (!core14.isDebug()) { + if (!core15.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99481,8 +99865,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch}`); - core14.debug(`source dir: ${sourceDir}`); + core15.debug(`Caching tool ${tool} ${version} ${arch}`); + core15.debug(`source dir: ${sourceDir}`); if (!fs8.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99499,14 +99883,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch}`); - core14.debug(`source file: ${sourceFile}`); + core15.debug(`Caching tool ${tool} ${version} ${arch}`); + core15.debug(`source file: ${sourceFile}`); if (!fs8.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch); const destPath = path7.join(destFolder, targetFile); - core14.debug(`destination file ${destPath}`); + core15.debug(`destination file ${destPath}`); yield io6.cp(sourceFile, destPath); _completeToolPath(tool, version, arch); return destFolder; @@ -99529,12 +99913,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path7.join(_getCacheDirectory(), toolName, versionSpec, arch); - core14.debug(`checking cache: ${cachePath}`); + core15.debug(`checking cache: ${cachePath}`); if (fs8.existsSync(cachePath) && fs8.existsSync(`${cachePath}.complete`)) { - core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); toolPath = cachePath; } else { - core14.debug("not found"); + core15.debug("not found"); } } return toolPath; @@ -99563,7 +99947,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99584,7 +99968,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core14.debug("Invalid json"); + core15.debug("Invalid json"); } } return releases; @@ -99608,7 +99992,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path7.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); - core14.debug(`destination ${folderPath}`); + core15.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io6.rmRF(folderPath); yield io6.rmRF(markerPath); @@ -99620,18 +100004,18 @@ var require_tool_cache = __commonJS({ const folderPath = path7.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); const markerPath = `${folderPath}.complete`; fs8.writeFileSync(markerPath, ""); - core14.debug("finished caching tool"); + core15.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core14.debug(`isExplicit: ${c}`); + core15.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core14.debug(`explicit? ${valid3}`); + core15.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core14.debug(`evaluating ${versions.length} versions`); + core15.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -99647,9 +100031,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core14.debug(`matched: ${version}`); + core15.debug(`matched: ${version}`); } else { - core14.debug("match not found"); + core15.debug("match not found"); } return version; } @@ -102331,14 +102715,14 @@ var require_retention = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getExpiration = void 0; var generated_1 = require_generated(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getExpiration(retentionDays) { if (!retentionDays) { return void 0; } const maxRetentionDays = getRetentionDays(); if (maxRetentionDays && maxRetentionDays < retentionDays) { - core14.warning(`Retention days cannot be greater than the maximum allowed retention set within the repository. Using ${maxRetentionDays} instead.`); + core15.warning(`Retention days cannot be greater than the maximum allowed retention set within the repository. Using ${maxRetentionDays} instead.`); retentionDays = maxRetentionDays; } const expirationDate = /* @__PURE__ */ new Date(); @@ -102676,7 +103060,7 @@ var require_util19 = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.maskSecretUrls = exports2.maskSigUrl = exports2.getBackendIdsFromToken = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var config_1 = require_config2(); var jwt_decode_1 = __importDefault2(require_jwt_decode_cjs()); var core_1 = require_core(); @@ -102703,8 +103087,8 @@ var require_util19 = __commonJS({ workflowRunBackendId: scopeParts[1], workflowJobRunBackendId: scopeParts[2] }; - core14.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); - core14.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); + core15.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); + core15.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); return ids; } throw InvalidJwtError; @@ -103064,7 +103448,7 @@ var require_blob_upload = __commonJS({ exports2.uploadZipToBlobStorage = void 0; var storage_blob_1 = require_commonjs15(); var config_1 = require_config2(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var crypto2 = __importStar2(require("crypto")); var stream = __importStar2(require("stream")); var errors_1 = require_errors4(); @@ -103090,9 +103474,9 @@ var require_blob_upload = __commonJS({ const bufferSize = (0, config_1.getUploadChunkSize)(); const blobClient = new storage_blob_1.BlobClient(authenticatedUploadURL); const blockBlobClient = blobClient.getBlockBlobClient(); - core14.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`); + core15.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`); const uploadCallback = (progress) => { - core14.info(`Uploaded bytes ${progress.loadedBytes}`); + core15.info(`Uploaded bytes ${progress.loadedBytes}`); uploadByteCount = progress.loadedBytes; lastProgressTime = Date.now(); }; @@ -103106,7 +103490,7 @@ var require_blob_upload = __commonJS({ const hashStream = crypto2.createHash("sha256"); zipUploadStream.pipe(uploadStream); zipUploadStream.pipe(hashStream).setEncoding("hex"); - core14.info("Beginning upload of artifact content to blob storage"); + core15.info("Beginning upload of artifact content to blob storage"); try { yield Promise.race([ blockBlobClient.uploadStream(uploadStream, bufferSize, maxConcurrency, options), @@ -103120,12 +103504,12 @@ var require_blob_upload = __commonJS({ } finally { abortController.abort(); } - core14.info("Finished uploading artifact content to blob storage!"); + core15.info("Finished uploading artifact content to blob storage!"); hashStream.end(); sha256Hash = hashStream.read(); - core14.info(`SHA256 digest of uploaded artifact zip is ${sha256Hash}`); + core15.info(`SHA256 digest of uploaded artifact zip is ${sha256Hash}`); if (uploadByteCount === 0) { - core14.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`); + core15.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`); } return { uploadSize: uploadByteCount, @@ -128466,7 +128850,7 @@ var require_zip2 = __commonJS({ var stream = __importStar2(require("stream")); var promises_1 = require("fs/promises"); var archiver2 = __importStar2(require_archiver()); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var config_1 = require_config2(); exports2.DEFAULT_COMPRESSION_LEVEL = 6; var ZipUploadStream = class extends stream.Transform { @@ -128483,7 +128867,7 @@ var require_zip2 = __commonJS({ exports2.ZipUploadStream = ZipUploadStream; function createZipUploadStream(uploadSpecification_1) { return __awaiter2(this, arguments, void 0, function* (uploadSpecification, compressionLevel = exports2.DEFAULT_COMPRESSION_LEVEL) { - core14.debug(`Creating Artifact archive with compressionLevel: ${compressionLevel}`); + core15.debug(`Creating Artifact archive with compressionLevel: ${compressionLevel}`); const zip = archiver2.create("zip", { highWaterMark: (0, config_1.getUploadChunkSize)(), zlib: { level: compressionLevel } @@ -128507,8 +128891,8 @@ var require_zip2 = __commonJS({ } const bufferSize = (0, config_1.getUploadChunkSize)(); const zipUploadStream = new ZipUploadStream(bufferSize); - core14.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`); - core14.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`); + core15.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`); + core15.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`); zip.pipe(zipUploadStream); zip.finalize(); return zipUploadStream; @@ -128516,24 +128900,24 @@ var require_zip2 = __commonJS({ } exports2.createZipUploadStream = createZipUploadStream; var zipErrorCallback = (error3) => { - core14.error("An error has occurred while creating the zip file for upload"); - core14.info(error3); + core15.error("An error has occurred while creating the zip file for upload"); + core15.info(error3); throw new Error("An error has occurred during zip creation for the artifact"); }; var zipWarningCallback = (error3) => { if (error3.code === "ENOENT") { - core14.warning("ENOENT warning during artifact zip creation. No such file or directory"); - core14.info(error3); + core15.warning("ENOENT warning during artifact zip creation. No such file or directory"); + core15.info(error3); } else { - core14.warning(`A non-blocking warning has occurred during artifact zip creation: ${error3.code}`); - core14.info(error3); + core15.warning(`A non-blocking warning has occurred during artifact zip creation: ${error3.code}`); + core15.info(error3); } }; var zipFinishCallback = () => { - core14.debug("Zip stream for upload has finished."); + core15.debug("Zip stream for upload has finished."); }; var zipEndCallback = () => { - core14.debug("Zip stream for upload has ended."); + core15.debug("Zip stream for upload has ended."); }; } }); @@ -128598,7 +128982,7 @@ var require_upload_artifact = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.uploadArtifact = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var retention_1 = require_retention(); var path_and_artifact_name_validation_1 = require_path_and_artifact_name_validation(); var artifact_twirp_client_1 = require_artifact_twirp_client2(); @@ -128645,13 +129029,13 @@ var require_upload_artifact = __commonJS({ value: `sha256:${uploadResult.sha256Hash}` }); } - core14.info(`Finalizing artifact upload`); + core15.info(`Finalizing artifact upload`); const finalizeArtifactResp = yield artifactClient.FinalizeArtifact(finalizeArtifactReq); if (!finalizeArtifactResp.ok) { throw new errors_1.InvalidResponseError("FinalizeArtifact: response from backend was not ok"); } const artifactId = BigInt(finalizeArtifactResp.artifactId); - core14.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`); + core15.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`); return { size: uploadResult.uploadSize, digest: uploadResult.sha256Hash, @@ -152132,7 +152516,7 @@ var require_download_artifact = __commonJS({ var crypto2 = __importStar2(require("crypto")); var stream = __importStar2(require("stream")); var github2 = __importStar2(require_github2()); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var httpClient = __importStar2(require_lib()); var unzip_stream_1 = __importDefault2(require_unzip()); var user_agent_1 = require_user_agent2(); @@ -152168,7 +152552,7 @@ var require_download_artifact = __commonJS({ return yield streamExtractExternal(url, directory); } catch (error3) { retryCount++; - core14.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); + core15.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); yield new Promise((resolve5) => setTimeout(resolve5, 5e3)); } } @@ -152198,7 +152582,7 @@ var require_download_artifact = __commonJS({ extractStream.on("data", () => { timer.refresh(); }).on("error", (error3) => { - core14.debug(`response.message: Artifact download failed: ${error3.message}`); + core15.debug(`response.message: Artifact download failed: ${error3.message}`); clearTimeout(timer); reject(error3); }).pipe(unzip_stream_1.default.Extract({ path: directory })).on("close", () => { @@ -152206,7 +152590,7 @@ var require_download_artifact = __commonJS({ if (hashStream) { hashStream.end(); sha256Digest = hashStream.read(); - core14.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); + core15.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); } resolve5({ sha256Digest: `sha256:${sha256Digest}` }); }).on("error", (error3) => { @@ -152221,7 +152605,7 @@ var require_download_artifact = __commonJS({ const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path); const api = github2.getOctokit(token); let digestMismatch = false; - core14.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`); + core15.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`); const { headers, status } = yield api.rest.actions.downloadArtifact({ owner: repositoryOwner, repo: repositoryName, @@ -152238,16 +152622,16 @@ var require_download_artifact = __commonJS({ if (!location) { throw new Error(`Unable to redirect to artifact download url`); } - core14.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`); + core15.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`); try { - core14.info(`Starting download of artifact to: ${downloadPath}`); + core15.info(`Starting download of artifact to: ${downloadPath}`); const extractResponse = yield streamExtract(location, downloadPath); - core14.info(`Artifact download completed successfully.`); + core15.info(`Artifact download completed successfully.`); if (options === null || options === void 0 ? void 0 : options.expectedHash) { if ((options === null || options === void 0 ? void 0 : options.expectedHash) !== extractResponse.sha256Digest) { digestMismatch = true; - core14.debug(`Computed digest: ${extractResponse.sha256Digest}`); - core14.debug(`Expected digest: ${options.expectedHash}`); + core15.debug(`Computed digest: ${extractResponse.sha256Digest}`); + core15.debug(`Expected digest: ${options.expectedHash}`); } } } catch (error3) { @@ -152274,7 +152658,7 @@ var require_download_artifact = __commonJS({ Are you trying to download from a different run? Try specifying a github-token with \`actions:read\` scope.`); } if (artifacts.length > 1) { - core14.warning("Multiple artifacts found, defaulting to first."); + core15.warning("Multiple artifacts found, defaulting to first."); } const signedReq = { workflowRunBackendId: artifacts[0].workflowRunBackendId, @@ -152282,16 +152666,16 @@ Are you trying to download from a different run? Try specifying a github-token w name: artifacts[0].name }; const { signedUrl } = yield artifactClient.GetSignedArtifactURL(signedReq); - core14.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`); + core15.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`); try { - core14.info(`Starting download of artifact to: ${downloadPath}`); + core15.info(`Starting download of artifact to: ${downloadPath}`); const extractResponse = yield streamExtract(signedUrl, downloadPath); - core14.info(`Artifact download completed successfully.`); + core15.info(`Artifact download completed successfully.`); if (options === null || options === void 0 ? void 0 : options.expectedHash) { if ((options === null || options === void 0 ? void 0 : options.expectedHash) !== extractResponse.sha256Digest) { digestMismatch = true; - core14.debug(`Computed digest: ${extractResponse.sha256Digest}`); - core14.debug(`Expected digest: ${options.expectedHash}`); + core15.debug(`Computed digest: ${extractResponse.sha256Digest}`); + core15.debug(`Expected digest: ${options.expectedHash}`); } } } catch (error3) { @@ -152304,10 +152688,10 @@ Are you trying to download from a different run? Try specifying a github-token w function resolveOrCreateDirectory() { return __awaiter2(this, arguments, void 0, function* (downloadPath = (0, config_1.getGitHubWorkspaceDir)()) { if (!(yield exists(downloadPath))) { - core14.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`); + core15.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`); yield promises_1.default.mkdir(downloadPath, { recursive: true }); } else { - core14.debug(`Artifact destination folder already exists: ${downloadPath}`); + core15.debug(`Artifact destination folder already exists: ${downloadPath}`); } return downloadPath; }); @@ -152348,7 +152732,7 @@ var require_retry_options = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getRetryOptions = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var defaultMaxRetryNumber = 5; var defaultExemptStatusCodes = [400, 401, 403, 404, 422]; function getRetryOptions(defaultOptions, retries = defaultMaxRetryNumber, exemptStatusCodes = defaultExemptStatusCodes) { @@ -152363,7 +152747,7 @@ var require_retry_options = __commonJS({ retryOptions.doNotRetry = exemptStatusCodes; } const requestOptions = Object.assign(Object.assign({}, defaultOptions.request), { retries }); - core14.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : "octokit default: [400, 401, 403, 404, 422]"})`); + core15.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : "octokit default: [400, 401, 403, 404, 422]"})`); return [retryOptions, requestOptions]; } exports2.getRetryOptions = getRetryOptions; @@ -152520,7 +152904,7 @@ var require_get_artifact = __commonJS({ exports2.getArtifactInternal = exports2.getArtifactPublic = void 0; var github_1 = require_github2(); var plugin_retry_1 = require_dist_node12(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var utils_1 = require_utils11(); var retry_options_1 = require_retry_options(); var plugin_request_log_1 = require_dist_node11(); @@ -152558,7 +152942,7 @@ var require_get_artifact = __commonJS({ let artifact2 = getArtifactResp.data.artifacts[0]; if (getArtifactResp.data.artifacts.length > 1) { artifact2 = getArtifactResp.data.artifacts.sort((a, b) => b.id - a.id)[0]; - core14.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.id})`); + core15.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.id})`); } return { artifact: { @@ -152591,7 +152975,7 @@ var require_get_artifact = __commonJS({ let artifact2 = res.artifacts[0]; if (res.artifacts.length > 1) { artifact2 = res.artifacts.sort((a, b) => Number(b.databaseId) - Number(a.databaseId))[0]; - core14.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.databaseId})`); + core15.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.databaseId})`); } return { artifact: { @@ -155699,7 +156083,7 @@ var require_core3 = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable6(name, val) { + function exportVariable7(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -155708,7 +156092,7 @@ var require_core3 = __commonJS({ } (0, command_1.issueCommand)("set-env", { name }, convertedVal); } - exports2.exportVariable = exportVariable6; + exports2.exportVariable = exportVariable7; function setSecret(secret) { (0, command_1.issueCommand)("add-mask", {}, secret); } @@ -157329,7 +157713,7 @@ var require_requestUtils2 = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.retryHttpClientRequest = exports2.retry = void 0; var utils_1 = require_utils13(); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var config_variables_1 = require_config_variables(); function retry2(name, operation, customErrorMessages, maxAttempts) { return __awaiter2(this, void 0, void 0, function* () { @@ -157356,13 +157740,13 @@ var require_requestUtils2 = __commonJS({ errorMessage = error3.message; } if (!isRetryable) { - core14.info(`${name} - Error is not retryable`); + core15.info(`${name} - Error is not retryable`); if (response) { (0, utils_1.displayHttpDiagnostics)(response); } break; } - core14.info(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core15.info(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); yield (0, utils_1.sleep)((0, utils_1.getExponentialRetryTimeInMilliseconds)(attempt)); attempt++; } @@ -157446,7 +157830,7 @@ var require_upload_http_client = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadHttpClient = void 0; var fs8 = __importStar2(require("fs")); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var tmp = __importStar2(require_tmp_promise()); var stream = __importStar2(require("stream")); var utils_1 = require_utils13(); @@ -157511,7 +157895,7 @@ var require_upload_http_client = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const FILE_CONCURRENCY = (0, config_variables_1.getUploadFileConcurrency)(); const MAX_CHUNK_SIZE = (0, config_variables_1.getUploadChunkSize)(); - core14.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`); + core15.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`); const parameters = []; let continueOnError = true; if (options) { @@ -157548,15 +157932,15 @@ var require_upload_http_client = __commonJS({ } const startTime = perf_hooks_1.performance.now(); const uploadFileResult = yield this.uploadFileAsync(index, currentFileParameters); - if (core14.isDebug()) { - core14.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`); + if (core15.isDebug()) { + core15.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`); } uploadFileSize += uploadFileResult.successfulUploadSize; totalFileSize += uploadFileResult.totalSize; if (uploadFileResult.isSuccess === false) { failedItemsToReport.push(currentFileParameters.file); if (!continueOnError) { - core14.error(`aborting artifact upload`); + core15.error(`aborting artifact upload`); abortPendingFileUploads = true; } } @@ -157565,7 +157949,7 @@ var require_upload_http_client = __commonJS({ }))); this.statusReporter.stop(); this.uploadHttpManager.disposeAndReplaceAllClients(); - core14.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`); + core15.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`); return { uploadSize: uploadFileSize, totalSize: totalFileSize, @@ -157591,16 +157975,16 @@ var require_upload_http_client = __commonJS({ let uploadFileSize = 0; let isGzip = true; if (!isFIFO && totalFileSize < 65536) { - core14.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`); + core15.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`); const buffer = yield (0, upload_gzip_1.createGZipFileInBuffer)(parameters.file); let openUploadStream; if (totalFileSize < buffer.byteLength) { - core14.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); + core15.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); openUploadStream = () => fs8.createReadStream(parameters.file); isGzip = false; uploadFileSize = totalFileSize; } else { - core14.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`); + core15.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`); openUploadStream = () => { const passThrough = new stream.PassThrough(); passThrough.end(buffer); @@ -157612,7 +157996,7 @@ var require_upload_http_client = __commonJS({ if (!result) { isUploadSuccessful = false; failedChunkSizes += uploadFileSize; - core14.warning(`Aborting upload for ${parameters.file} due to failure`); + core15.warning(`Aborting upload for ${parameters.file} due to failure`); } return { isSuccess: isUploadSuccessful, @@ -157621,16 +158005,16 @@ var require_upload_http_client = __commonJS({ }; } else { const tempFile = yield tmp.file(); - core14.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`); + core15.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`); uploadFileSize = yield (0, upload_gzip_1.createGZipFileOnDisk)(parameters.file, tempFile.path); let uploadFilePath = tempFile.path; if (!isFIFO && totalFileSize < uploadFileSize) { - core14.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); + core15.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); uploadFileSize = totalFileSize; uploadFilePath = parameters.file; isGzip = false; } else { - core14.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`); + core15.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`); } let abortFileUpload = false; while (offset < uploadFileSize) { @@ -157650,7 +158034,7 @@ var require_upload_http_client = __commonJS({ if (!result) { isUploadSuccessful = false; failedChunkSizes += chunkSize; - core14.warning(`Aborting upload for ${parameters.file} due to failure`); + core15.warning(`Aborting upload for ${parameters.file} due to failure`); abortFileUpload = true; } else { if (uploadFileSize > 8388608) { @@ -157658,7 +158042,7 @@ var require_upload_http_client = __commonJS({ } } } - core14.debug(`deleting temporary gzip file ${tempFile.path}`); + core15.debug(`deleting temporary gzip file ${tempFile.path}`); yield tempFile.cleanup(); return { isSuccess: isUploadSuccessful, @@ -157697,7 +158081,7 @@ var require_upload_http_client = __commonJS({ if (response) { (0, utils_1.displayHttpDiagnostics)(response); } - core14.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`); + core15.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`); return true; } return false; @@ -157705,14 +158089,14 @@ var require_upload_http_client = __commonJS({ const backOff = (retryAfterValue) => __awaiter2(this, void 0, void 0, function* () { this.uploadHttpManager.disposeAndReplaceClient(httpClientIndex); if (retryAfterValue) { - core14.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`); + core15.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`); yield (0, utils_1.sleep)(retryAfterValue); } else { const backoffTime = (0, utils_1.getExponentialRetryTimeInMilliseconds)(retryCount); - core14.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`); + core15.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`); yield (0, utils_1.sleep)(backoffTime); } - core14.info(`Finished backoff for retry #${retryCount}, continuing with upload`); + core15.info(`Finished backoff for retry #${retryCount}, continuing with upload`); return; }); while (retryCount <= retryLimit) { @@ -157720,7 +158104,7 @@ var require_upload_http_client = __commonJS({ try { response = yield uploadChunkRequest(); } catch (error3) { - core14.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`); + core15.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`); console.log(error3); if (incrementAndCheckRetryLimit()) { return false; @@ -157732,13 +158116,13 @@ var require_upload_http_client = __commonJS({ if ((0, utils_1.isSuccessStatusCode)(response.message.statusCode)) { return true; } else if ((0, utils_1.isRetryableStatusCode)(response.message.statusCode)) { - core14.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`); + core15.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`); if (incrementAndCheckRetryLimit(response)) { return false; } (0, utils_1.isThrottledStatusCode)(response.message.statusCode) ? yield backOff((0, utils_1.tryGetRetryAfterValueTimeInMilliseconds)(response.message.headers)) : yield backOff(); } else { - core14.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`); + core15.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`); (0, utils_1.displayHttpDiagnostics)(response); return false; } @@ -157756,7 +158140,7 @@ var require_upload_http_client = __commonJS({ resourceUrl.searchParams.append("artifactName", artifactName); const parameters = { Size: size }; const data = JSON.stringify(parameters, null, 2); - core14.debug(`URL is ${resourceUrl.toString()}`); + core15.debug(`URL is ${resourceUrl.toString()}`); const client = this.uploadHttpManager.getClient(0); const headers = (0, utils_1.getUploadHeaders)("application/json", false); const customErrorMessages = /* @__PURE__ */ new Map([ @@ -157769,7 +158153,7 @@ var require_upload_http_client = __commonJS({ return client.patch(resourceUrl.toString(), data, headers); }), customErrorMessages); yield response.readBody(); - core14.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`); + core15.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`); }); } }; @@ -157838,7 +158222,7 @@ var require_download_http_client = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DownloadHttpClient = void 0; var fs8 = __importStar2(require("fs")); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var zlib = __importStar2(require("zlib")); var utils_1 = require_utils13(); var url_1 = require("url"); @@ -157892,11 +158276,11 @@ var require_download_http_client = __commonJS({ downloadSingleArtifact(downloadItems) { return __awaiter2(this, void 0, void 0, function* () { const DOWNLOAD_CONCURRENCY = (0, config_variables_1.getDownloadFileConcurrency)(); - core14.debug(`Download file concurrency is set to ${DOWNLOAD_CONCURRENCY}`); + core15.debug(`Download file concurrency is set to ${DOWNLOAD_CONCURRENCY}`); const parallelDownloads = [...new Array(DOWNLOAD_CONCURRENCY).keys()]; let currentFile = 0; let downloadedFiles = 0; - core14.info(`Total number of files that will be downloaded: ${downloadItems.length}`); + core15.info(`Total number of files that will be downloaded: ${downloadItems.length}`); this.statusReporter.setTotalNumberOfFilesToProcess(downloadItems.length); this.statusReporter.start(); yield Promise.all(parallelDownloads.map((index) => __awaiter2(this, void 0, void 0, function* () { @@ -157905,8 +158289,8 @@ var require_download_http_client = __commonJS({ currentFile += 1; const startTime = perf_hooks_1.performance.now(); yield this.downloadIndividualFile(index, currentFileToDownload.sourceLocation, currentFileToDownload.targetPath); - if (core14.isDebug()) { - core14.debug(`File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish downloading`); + if (core15.isDebug()) { + core15.debug(`File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish downloading`); } this.statusReporter.incrementProcessedCount(); } @@ -157944,19 +158328,19 @@ var require_download_http_client = __commonJS({ } else { this.downloadHttpManager.disposeAndReplaceClient(httpClientIndex); if (retryAfterValue) { - core14.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the download`); + core15.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the download`); yield (0, utils_1.sleep)(retryAfterValue); } else { const backoffTime = (0, utils_1.getExponentialRetryTimeInMilliseconds)(retryCount); - core14.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the download`); + core15.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the download`); yield (0, utils_1.sleep)(backoffTime); } - core14.info(`Finished backoff for retry #${retryCount}, continuing with download`); + core15.info(`Finished backoff for retry #${retryCount}, continuing with download`); } }); const isAllBytesReceived = (expected, received) => { if (!expected || !received || process.env["ACTIONS_ARTIFACT_SKIP_DOWNLOAD_VALIDATION"]) { - core14.info("Skipping download validation."); + core15.info("Skipping download validation."); return true; } return parseInt(expected) === received; @@ -157977,7 +158361,7 @@ var require_download_http_client = __commonJS({ try { response = yield makeDownloadRequest(); } catch (error3) { - core14.info("An error occurred while attempting to download a file"); + core15.info("An error occurred while attempting to download a file"); console.log(error3); yield backOff(); continue; @@ -157997,7 +158381,7 @@ var require_download_http_client = __commonJS({ } } if (forceRetry || (0, utils_1.isRetryableStatusCode)(response.message.statusCode)) { - core14.info(`A ${response.message.statusCode} response code has been received while attempting to download an artifact`); + core15.info(`A ${response.message.statusCode} response code has been received while attempting to download an artifact`); resetDestinationStream(downloadPath); (0, utils_1.isThrottledStatusCode)(response.message.statusCode) ? yield backOff((0, utils_1.tryGetRetryAfterValueTimeInMilliseconds)(response.message.headers)) : yield backOff(); } else { @@ -158019,29 +158403,29 @@ var require_download_http_client = __commonJS({ if (isGzip) { const gunzip = zlib.createGunzip(); response.message.on("error", (error3) => { - core14.info(`An error occurred while attempting to read the response stream`); + core15.info(`An error occurred while attempting to read the response stream`); gunzip.close(); destinationStream.close(); reject(error3); }).pipe(gunzip).on("error", (error3) => { - core14.info(`An error occurred while attempting to decompress the response stream`); + core15.info(`An error occurred while attempting to decompress the response stream`); destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { resolve5(); }).on("error", (error3) => { - core14.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); + core15.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); }); } else { response.message.on("error", (error3) => { - core14.info(`An error occurred while attempting to read the response stream`); + core15.info(`An error occurred while attempting to read the response stream`); destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { resolve5(); }).on("error", (error3) => { - core14.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); + core15.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); }); } @@ -158180,7 +158564,7 @@ var require_artifact_client = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultArtifactClient = void 0; - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var upload_specification_1 = require_upload_specification(); var upload_http_client_1 = require_upload_http_client(); var utils_1 = require_utils13(); @@ -158201,7 +158585,7 @@ var require_artifact_client = __commonJS({ */ uploadArtifact(name, files, rootDirectory, options) { return __awaiter2(this, void 0, void 0, function* () { - core14.info(`Starting artifact upload + core15.info(`Starting artifact upload For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging`); (0, path_and_artifact_name_validation_1.checkArtifactName)(name); const uploadSpecification = (0, upload_specification_1.getUploadSpecification)(name, rootDirectory, files); @@ -158213,24 +158597,24 @@ For more detailed logs during the artifact upload process, enable step-debugging }; const uploadHttpClient = new upload_http_client_1.UploadHttpClient(); if (uploadSpecification.length === 0) { - core14.warning(`No files found that can be uploaded`); + core15.warning(`No files found that can be uploaded`); } else { const response = yield uploadHttpClient.createArtifactInFileContainer(name, options); if (!response.fileContainerResourceUrl) { - core14.debug(response.toString()); + core15.debug(response.toString()); throw new Error("No URL provided by the Artifact Service to upload an artifact to"); } - core14.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); - core14.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`); + core15.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); + core15.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`); const uploadResult = yield uploadHttpClient.uploadArtifactToFileContainer(response.fileContainerResourceUrl, uploadSpecification, options); - core14.info(`File upload process has finished. Finalizing the artifact upload`); + core15.info(`File upload process has finished. Finalizing the artifact upload`); yield uploadHttpClient.patchArtifactSize(uploadResult.totalSize, name); if (uploadResult.failedItems.length > 0) { - core14.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`); + core15.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`); } else { - core14.info(`Artifact has been finalized. All files have been successfully uploaded!`); + core15.info(`Artifact has been finalized. All files have been successfully uploaded!`); } - core14.info(` + core15.info(` The raw size of all the files that were specified for upload is ${uploadResult.totalSize} bytes The size of all the files that were uploaded is ${uploadResult.uploadSize} bytes. This takes into account any gzip compression used to reduce the upload size, time and storage @@ -158264,10 +158648,10 @@ Note: The size of downloaded zips can differ significantly from the reported siz path7 = (0, path_1.resolve)(path7); const downloadSpecification = (0, download_specification_1.getDownloadSpecification)(name, items.value, path7, (options === null || options === void 0 ? void 0 : options.createArtifactFolder) || false); if (downloadSpecification.filesToDownload.length === 0) { - core14.info(`No downloadable files were found for the artifact: ${artifactToDownload.name}`); + core15.info(`No downloadable files were found for the artifact: ${artifactToDownload.name}`); } else { yield (0, utils_1.createDirectoriesForArtifact)(downloadSpecification.directoryStructure); - core14.info("Directory structure has been set up for the artifact"); + core15.info("Directory structure has been set up for the artifact"); yield (0, utils_1.createEmptyFilesForArtifact)(downloadSpecification.emptyFilesToCreate); yield downloadHttpClient.downloadSingleArtifact(downloadSpecification.filesToDownload); } @@ -158283,7 +158667,7 @@ Note: The size of downloaded zips can differ significantly from the reported siz const response = []; const artifacts = yield downloadHttpClient.listArtifacts(); if (artifacts.count === 0) { - core14.info("Unable to find any artifacts for the associated workflow"); + core15.info("Unable to find any artifacts for the associated workflow"); return response; } if (!path7) { @@ -158295,11 +158679,11 @@ Note: The size of downloaded zips can differ significantly from the reported siz while (downloadedArtifacts < artifacts.count) { const currentArtifactToDownload = artifacts.value[downloadedArtifacts]; downloadedArtifacts += 1; - core14.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`); + core15.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`); const items = yield downloadHttpClient.getContainerItems(currentArtifactToDownload.name, currentArtifactToDownload.fileContainerResourceUrl); const downloadSpecification = (0, download_specification_1.getDownloadSpecification)(currentArtifactToDownload.name, items.value, path7, true); if (downloadSpecification.filesToDownload.length === 0) { - core14.info(`No downloadable files were found for any artifact ${currentArtifactToDownload.name}`); + core15.info(`No downloadable files were found for any artifact ${currentArtifactToDownload.name}`); } else { yield (0, utils_1.createDirectoriesForArtifact)(downloadSpecification.directoryStructure); yield (0, utils_1.createEmptyFilesForArtifact)(downloadSpecification.emptyFilesToCreate); @@ -158334,7 +158718,7 @@ var require_artifact_client2 = __commonJS({ // src/analyze-action-post.ts var fs7 = __toESM(require("fs")); -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); // src/actions-util.ts var fs = __toESM(require("fs")); @@ -161143,7 +161527,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -161359,7 +161743,7 @@ async function getGitHubVersion() { // src/codeql.ts var fs4 = __toESM(require("fs")); var path4 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -161607,6 +161991,7 @@ function wrapCliConfigurationError(cliError) { // src/config-utils.ts var fs3 = __toESM(require("fs")); var path3 = __toESM(require("path")); +var core9 = __toESM(require_core()); // src/analyses.ts var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => { @@ -161840,6 +162225,7 @@ async function isAnalyzingDefaultBranch() { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -161991,6 +162377,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -162021,6 +162412,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -162031,16 +162427,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -162056,15 +162442,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -162125,6 +162527,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -162133,6 +162536,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -162195,7 +162599,7 @@ var toolcache = __toESM(require_tool_cache()); var semver6 = __toESM(require_semver2()); // src/tools-download.ts -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -162220,7 +162624,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function getCodeQL(cmd) { if (cachedCodeQL === void 0) { cachedCodeQL = await getCodeQLForCmd(cmd, true); @@ -162516,17 +162919,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -162675,12 +163074,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core10.warning( + core11.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core10.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -162790,14 +163189,14 @@ var fs6 = __toESM(require("fs")); var path6 = __toESM(require("path")); var artifact = __toESM(require_artifact2()); var artifactLegacy = __toESM(require_artifact_client2()); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); var import_archiver = __toESM(require_archiver()); // src/analyze.ts var io5 = __toESM(require_io()); // src/autobuild.ts -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); // src/dependency-caching.ts var import_path = require("path"); @@ -163105,10 +163504,10 @@ function getArtifactSuffix(matrix) { for (const matrixKey of Object.keys(matrixObject).sort()) suffix += `-${matrixObject[matrixKey]}`; } else { - core12.warning("User-specified `matrix` input is not an object."); + core13.warning("User-specified `matrix` input is not an object."); } } catch { - core12.warning( + core13.warning( "Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input." ); } @@ -163118,7 +163517,7 @@ function getArtifactSuffix(matrix) { async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghVariant, codeQlVersion) { const uploadSupported = isSafeArtifactUpload(codeQlVersion); if (!uploadSupported) { - core12.info( + core13.info( `Skipping debug artifact upload because the current CLI does not support safe upload. Please upgrade to CLI v${SafeArtifactUploadVersion} or later.` ); return "upload-not-supported"; @@ -163131,7 +163530,7 @@ async function uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVarian } if (isInTestMode()) { await scanArtifactsForTokens(toUpload, logger); - core12.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true"); + core13.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true"); } const suffix = getArtifactSuffix(getOptionalInput("matrix")); const artifactUploader = await getArtifactUploaderClient(logger, ghVariant); @@ -163147,7 +163546,7 @@ async function uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVarian ); return "upload-successful"; } catch (e) { - core12.warning(`Failed to upload debug artifacts: ${e}`); + core13.warning(`Failed to upload debug artifacts: ${e}`); return "upload-failed"; } } @@ -163203,7 +163602,7 @@ async function runWrapper() { } } } catch (error3) { - core13.setFailed( + core14.setFailed( `analyze post-action step failed: ${getErrorMessage(error3)}` ); } diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 07250a0750..fbb9e81416 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable9; + exports2.exportVariable = exportVariable10; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable9(name, val) { + function exportVariable10(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -48640,7 +48640,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -48652,23 +48652,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core16.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core17.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core16.debug(`implicitDescendants '${result.implicitDescendants}'`); + core17.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core16.debug(`matchDirectories '${result.matchDirectories}'`); + core17.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core16.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core17.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core16.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core17.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -50296,7 +50296,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var fs18 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path16 = __importStar2(require("path")); @@ -50349,7 +50349,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core16.debug(`Search path '${searchPath}'`); + core17.debug(`Search path '${searchPath}'`); try { yield __await2(fs18.promises.lstat(searchPath)); } catch (err) { @@ -50424,7 +50424,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core16.debug(`Broken symlink '${item.path}'`); + core17.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -50440,7 +50440,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core16.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core17.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -50543,7 +50543,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles2; var crypto3 = __importStar2(require("crypto")); - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var fs18 = __importStar2(require("fs")); var stream2 = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -50552,7 +50552,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core16.info : core16.debug; + const writeDelegate = verbose ? core17.info : core17.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto3.createHash("sha256"); @@ -51943,7 +51943,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var exec = __importStar2(require_exec()); var glob2 = __importStar2(require_glob()); var io7 = __importStar2(require_io()); @@ -51994,7 +51994,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path16.relative(workspace, file).replace(new RegExp(`\\${path16.sep}`, "g"), "/"); - core16.debug(`Matched: ${relativeFile}`); + core17.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -52022,7 +52022,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core16.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core17.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -52033,10 +52033,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core16.debug(err.message); + core17.debug(err.message); } versionOutput = versionOutput.trim(); - core16.debug(versionOutput); + core17.debug(versionOutput); return versionOutput; }); } @@ -52044,7 +52044,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core16.debug(`zstd version: ${version}`); + core17.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -61827,44 +61827,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -61872,63 +61872,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61937,16 +61937,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61955,83 +61955,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62045,190 +62052,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -62238,290 +62454,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + } + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - function H(t2, e2, n2) { - let i2; + function lt(t2, e2, i2) { + return pt(t2, e2, i2); + } + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62530,172 +62781,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } } - return s2; + return i2; } - function ot(t2) { + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + } + return i2; + } + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -91700,7 +92084,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -91742,7 +92126,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core16.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core17.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91799,14 +92183,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core16.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core17.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core16.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core17.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -91891,7 +92275,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -91949,9 +92333,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core16.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core17.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core16.debug(`${name} - Error is not retryable`); + core17.debug(`${name} - Error is not retryable`); break; } yield sleep(delay2); @@ -92210,7 +92594,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -92248,7 +92632,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core16.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core17.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -92282,7 +92666,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core16.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core17.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -92332,7 +92716,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core16.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core17.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -92343,7 +92727,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core16.debug("Unable to validate download, no Content-Length header"); + core17.debug("Unable to validate download, no Content-Length header"); } }); } @@ -92461,7 +92845,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core16.debug("Unable to determine content length, downloading file with http-client..."); + core17.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -92551,7 +92935,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -92571,9 +92955,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core16.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core16.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core16.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core17.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core17.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core17.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -92609,12 +92993,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core16.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core16.debug(`Download concurrency: ${result.downloadConcurrency}`); - core16.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core16.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core16.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core16.debug(`Lookup only: ${result.lookupOnly}`); + core17.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core17.debug(`Download concurrency: ${result.downloadConcurrency}`); + core17.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core17.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core17.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core17.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -92808,7 +93192,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache5; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs18 = __importStar2(require("fs")); @@ -92826,7 +93210,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url2 = `${baseUrl}_apis/artifactcache/${resource}`; - core16.debug(`Resource Url: ${url2}`); + core17.debug(`Resource Url: ${url2}`); return url2; } function createAcceptHeader(type2, apiVersion) { @@ -92854,7 +93238,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core16.isDebug()) { + if (core17.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -92867,9 +93251,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core16.setSecret(cacheDownloadUrl); - core16.debug(`Cache Result:`); - core16.debug(JSON.stringify(cacheResult)); + core17.setSecret(cacheDownloadUrl); + core17.debug(`Cache Result:`); + core17.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -92883,10 +93267,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core16.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core17.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core16.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core17.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -92929,7 +93313,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core16.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core17.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -92951,7 +93335,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core16.debug("Awaiting all uploads"); + core17.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -92994,16 +93378,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core16.debug("Upload cache"); + core17.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core16.debug("Commiting cache"); + core17.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core16.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core17.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core16.info("Cache saved successfully"); + core17.info("Cache saved successfully"); } }); } @@ -98486,7 +98870,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache5; exports2.saveCache = saveCache5; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var path16 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -98545,7 +98929,7 @@ var require_cache5 = __commonJS({ function restoreCache5(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core16.debug(`Cache service version: ${cacheServiceVersion}`); + core17.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -98560,8 +98944,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core16.debug("Resolved Keys:"); - core16.debug(JSON.stringify(keys)); + core17.debug("Resolved Keys:"); + core17.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98579,19 +98963,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core16.info("Lookup only - skipping download"); + core17.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path16.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core16.debug(`Archive Path: ${archivePath}`); + core17.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core16.isDebug()) { + if (core17.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core16.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core17.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core16.info("Cache restored successfully"); + core17.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -98599,16 +98983,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core16.error(`Failed to restore: ${error3.message}`); + core17.error(`Failed to restore: ${error3.message}`); } else { - core16.warning(`Failed to restore: ${error3.message}`); + core17.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core16.debug(`Failed to delete archive: ${error3}`); + core17.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98619,8 +99003,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core16.debug("Resolved Keys:"); - core16.debug(JSON.stringify(keys)); + core17.debug("Resolved Keys:"); + core17.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98638,30 +99022,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core16.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core17.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core16.info(`Cache hit for restore-key: ${response.matchedKey}`); + core17.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core16.info(`Cache hit for: ${response.matchedKey}`); + core17.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core16.info("Lookup only - skipping download"); + core17.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path16.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core16.debug(`Archive path: ${archivePath}`); - core16.debug(`Starting download of archive to: ${archivePath}`); + core17.debug(`Archive path: ${archivePath}`); + core17.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core16.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core16.isDebug()) { + core17.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core17.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core16.info("Cache restored successfully"); + core17.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -98669,9 +99053,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core16.error(`Failed to restore: ${error3.message}`); + core17.error(`Failed to restore: ${error3.message}`); } else { - core16.warning(`Failed to restore: ${error3.message}`); + core17.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -98680,7 +99064,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core16.debug(`Failed to delete archive: ${error3}`); + core17.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98689,7 +99073,7 @@ var require_cache5 = __commonJS({ function saveCache5(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core16.debug(`Cache service version: ${cacheServiceVersion}`); + core17.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -98707,26 +99091,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core16.debug("Cache Paths:"); - core16.debug(`${JSON.stringify(cachePaths)}`); + core17.debug("Cache Paths:"); + core17.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path16.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core16.debug(`Archive Path: ${archivePath}`); + core17.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core16.isDebug()) { + if (core17.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core16.debug(`File Size: ${archiveFileSize}`); + core17.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core16.debug("Reserving Cache"); + core17.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -98739,26 +99123,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core16.debug(`Saving Cache (ID: ${cacheId})`); + core17.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core16.info(`Failed to save: ${typedError.message}`); + core17.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core16.error(`Failed to save: ${typedError.message}`); + core17.error(`Failed to save: ${typedError.message}`); } else { - core16.warning(`Failed to save: ${typedError.message}`); + core17.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core16.debug(`Failed to delete archive: ${error3}`); + core17.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -98771,23 +99155,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core16.debug("Cache Paths:"); - core16.debug(`${JSON.stringify(cachePaths)}`); + core17.debug("Cache Paths:"); + core17.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path16.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core16.debug(`Archive Path: ${archivePath}`); + core17.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core16.isDebug()) { + if (core17.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core16.debug(`File Size: ${archiveFileSize}`); + core17.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core16.debug("Reserving Cache"); + core17.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -98798,16 +99182,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core16.warning(`Cache reservation failed: ${response.message}`); + core17.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core16.debug(`Failed to reserve cache: ${error3}`); + core17.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core16.debug(`Attempting to upload cache located at: ${archivePath}`); + core17.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -98815,7 +99199,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core16.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core17.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -98828,21 +99212,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core16.info(`Failed to save: ${typedError.message}`); + core17.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core16.warning(typedError.message); + core17.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core16.error(`Failed to save: ${typedError.message}`); + core17.error(`Failed to save: ${typedError.message}`); } else { - core16.warning(`Failed to save: ${typedError.message}`); + core17.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core16.debug(`Failed to delete archive: ${error3}`); + core17.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99069,7 +99453,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99092,10 +99476,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core16.info(err.message); + core17.info(err.message); } const seconds = this.getSleepAmount(); - core16.info(`Waiting ${seconds} seconds before trying again`); + core17.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99198,7 +99582,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core16 = __importStar2(require_core()); + var core17 = __importStar2(require_core()); var io7 = __importStar2(require_io()); var crypto3 = __importStar2(require("crypto")); var fs18 = __importStar2(require("fs")); @@ -99227,8 +99611,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path16.join(_getTempDirectory(), crypto3.randomUUID()); yield io7.mkdirP(path16.dirname(dest)); - core16.debug(`Downloading ${url2}`); - core16.debug(`Destination ${dest}`); + core17.debug(`Downloading ${url2}`); + core17.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99254,7 +99638,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core16.debug("set auth"); + core17.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99263,7 +99647,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url2, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core16.debug(`Failed to download from "${url2}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core17.debug(`Failed to download from "${url2}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream2.pipeline); @@ -99272,16 +99656,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs18.createWriteStream(dest)); - core16.debug("download complete"); + core17.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core16.debug("download failed"); + core17.debug("download failed"); try { yield io7.rmRF(dest); } catch (err) { - core16.debug(`Failed to delete '${dest}'. ${err.message}`); + core17.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99296,7 +99680,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core16.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core17.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core16.debug("Checking tar --version"); + core17.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99359,7 +99743,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core16.debug(versionOutput.trim()); + core17.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99367,7 +99751,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core16.isDebug() && !flags.includes("v")) { + if (core17.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99398,7 +99782,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core16.isDebug()) { + if (core17.isDebug()) { args.push("-v"); } const xarPath = yield io7.which("xar", true); @@ -99441,7 +99825,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core16.debug(`Using pwsh at path: ${pwshPath}`); + core17.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99461,7 +99845,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io7.which("powershell", true); - core16.debug(`Using powershell at path: ${powershellPath}`); + core17.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99470,7 +99854,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io7.which("unzip", true); const args = [file]; - if (!core16.isDebug()) { + if (!core17.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99481,8 +99865,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os5.arch(); - core16.debug(`Caching tool ${tool} ${version} ${arch2}`); - core16.debug(`source dir: ${sourceDir}`); + core17.debug(`Caching tool ${tool} ${version} ${arch2}`); + core17.debug(`source dir: ${sourceDir}`); if (!fs18.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99499,14 +99883,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os5.arch(); - core16.debug(`Caching tool ${tool} ${version} ${arch2}`); - core16.debug(`source file: ${sourceFile}`); + core17.debug(`Caching tool ${tool} ${version} ${arch2}`); + core17.debug(`source file: ${sourceFile}`); if (!fs18.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch2); const destPath = path16.join(destFolder, targetFile); - core16.debug(`destination file ${destPath}`); + core17.debug(`destination file ${destPath}`); yield io7.cp(sourceFile, destPath); _completeToolPath(tool, version, arch2); return destFolder; @@ -99529,12 +99913,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path16.join(_getCacheDirectory(), toolName, versionSpec, arch2); - core16.debug(`checking cache: ${cachePath}`); + core17.debug(`checking cache: ${cachePath}`); if (fs18.existsSync(cachePath) && fs18.existsSync(`${cachePath}.complete`)) { - core16.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); + core17.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); toolPath = cachePath; } else { - core16.debug("not found"); + core17.debug("not found"); } } return toolPath; @@ -99563,7 +99947,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core16.debug("set auth"); + core17.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99584,7 +99968,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core16.debug("Invalid json"); + core17.debug("Invalid json"); } } return releases; @@ -99608,7 +99992,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch2) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path16.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); - core16.debug(`destination ${folderPath}`); + core17.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io7.rmRF(folderPath); yield io7.rmRF(markerPath); @@ -99620,18 +100004,18 @@ var require_tool_cache = __commonJS({ const folderPath = path16.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); const markerPath = `${folderPath}.complete`; fs18.writeFileSync(markerPath, ""); - core16.debug("finished caching tool"); + core17.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core16.debug(`isExplicit: ${c}`); + core17.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core16.debug(`explicit? ${valid3}`); + core17.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core16.debug(`evaluating ${versions.length} versions`); + core17.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -99647,9 +100031,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core16.debug(`matched: ${version}`); + core17.debug(`matched: ${version}`); } else { - core16.debug("match not found"); + core17.debug("match not found"); } return version; } @@ -103129,7 +103513,7 @@ module.exports = __toCommonJS(analyze_action_exports); var fs17 = __toESM(require("fs")); var import_path4 = __toESM(require("path")); var import_perf_hooks3 = require("perf_hooks"); -var core15 = __toESM(require_core()); +var core16 = __toESM(require_core()); // src/actions-util.ts var fs2 = __toESM(require("fs")); @@ -106312,7 +106696,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -106581,7 +106965,7 @@ var import_perf_hooks2 = require("perf_hooks"); var io5 = __toESM(require_io()); // src/autobuild.ts -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); // src/api-client.ts var core5 = __toESM(require_core()); @@ -106857,7 +107241,7 @@ function wrapApiConfigurationError(e) { // src/codeql.ts var fs11 = __toESM(require("fs")); var path11 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -107105,6 +107489,7 @@ function wrapCliConfigurationError(cliError) { // src/config-utils.ts var fs6 = __toESM(require("fs")); var path7 = __toESM(require("path")); +var core9 = __toESM(require_core()); // src/caching-utils.ts var crypto2 = __toESM(require("crypto")); @@ -107251,8 +107636,8 @@ var path5 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.24.3"; -var cliVersion = "2.24.3"; +var bundleVersion = "codeql-bundle-v2.25.0"; +var cliVersion = "2.25.0"; // src/overlay/index.ts var fs3 = __toESM(require("fs")); @@ -107460,6 +107845,7 @@ async function isAnalyzingDefaultBranch() { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -107745,6 +108131,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -107775,6 +108166,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -107785,16 +108181,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -107810,15 +108196,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -108287,14 +108689,13 @@ Error Response: ${JSON.stringify(error3.response, null, 2)}` } } function getDiffRanges(fileDiff, logger) { - const filename = path6.join(getRequiredInput("checkout_path"), fileDiff.filename).replaceAll(path6.sep, "/"); if (fileDiff.patch === void 0) { if (fileDiff.changes === 0) { return []; } return [ { - path: filename, + path: fileDiff.filename, startLine: 0, endLine: 0 } @@ -108318,7 +108719,7 @@ function getDiffRanges(fileDiff, logger) { } if (additionRangeStartLine !== void 0) { diffRanges.push({ - path: filename, + path: fileDiff.filename, startLine: additionRangeStartLine, endLine: currentLine - 1 }); @@ -108475,6 +108876,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -108483,6 +108885,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -108772,7 +109175,7 @@ var fs8 = __toESM(require("fs")); var os2 = __toESM(require("os")); var path8 = __toESM(require("path")); var import_perf_hooks = require("perf_hooks"); -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -108826,10 +109229,10 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat }; } } catch (e) { - core9.warning( + core10.warning( `Failed to download and extract CodeQL bundle using streaming with error: ${getErrorMessage(e)}` ); - core9.warning(`Falling back to downloading the bundle before extracting.`); + core10.warning(`Falling back to downloading the bundle before extracting.`); await cleanUpPath(dest, "CodeQL bundle", logger); } const toolsDownloadStart = import_perf_hooks.performance.now(); @@ -109544,7 +109947,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, checkVersion) { try { const { @@ -109888,17 +110290,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -110047,12 +110445,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core10.warning( + core11.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core10.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -110174,16 +110572,16 @@ async function setupCppAutobuild(codeql, logger) { logger.info( `Disabling ${featureName} as we are on a self-hosted runner.${getWorkflowEventName() !== "dynamic" ? ` To override this, set the ${envVar} environment variable to 'true' in your workflow. See ${"https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow" /* DEFINE_ENV_VARIABLES */} for more information.` : ""}` ); - core11.exportVariable(envVar, "false"); + core12.exportVariable(envVar, "false"); } else { logger.info( `Enabling ${featureName}. This can be disabled by setting the ${envVar} environment variable to 'false'. See ${"https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow" /* DEFINE_ENV_VARIABLES */} for more information.` ); - core11.exportVariable(envVar, "true"); + core12.exportVariable(envVar, "true"); } } else { logger.info(`Disabling ${featureName}.`); - core11.exportVariable(envVar, "false"); + core12.exportVariable(envVar, "false"); } } async function runAutobuild(config, language, logger) { @@ -110198,7 +110596,7 @@ async function runAutobuild(config, language, logger) { await codeQL.runAutobuild(config, language); } if (language === "go" /* go */) { - core11.exportVariable("CODEQL_ACTION_DID_AUTOBUILD_GOLANG" /* DID_AUTOBUILD_GOLANG */, "true"); + core12.exportVariable("CODEQL_ACTION_DID_AUTOBUILD_GOLANG" /* DID_AUTOBUILD_GOLANG */, "true"); } logger.endGroup(); } @@ -110506,7 +110904,12 @@ async function setupDiffInformedQueryRun(branches, logger) { `Calculating diff ranges for ${branches.base}...${branches.head}` ); const diffRanges = await getPullRequestEditedDiffRanges(branches, logger); - const packDir = writeDiffRangeDataExtensionPack(logger, diffRanges); + const checkoutPath = getRequiredInput("checkout_path"); + const packDir = writeDiffRangeDataExtensionPack( + logger, + diffRanges, + checkoutPath + ); if (packDir === void 0) { logger.warning( "Cannot create diff range extension pack for diff-informed queries; reverting to performing full analysis." @@ -110520,7 +110923,26 @@ async function setupDiffInformedQueryRun(branches, logger) { } ); } -function writeDiffRangeDataExtensionPack(logger, ranges) { +function diffRangeExtensionPackContents(ranges, checkoutPath) { + const header = ` +extensions: + - addsTo: + pack: codeql/util + extensible: restrictAlertsTo + checkPresence: false + data: +`; + let data = ranges.map((range) => { + const filename = path12.join(checkoutPath, range.path).replaceAll(path12.sep, "/"); + return ` - [${dump(filename, { forceQuotes: true }).trim()}, ${range.startLine}, ${range.endLine}] +`; + }).join(""); + if (!data) { + data = ' - ["", 0, 0]\n'; + } + return header + data; +} +function writeDiffRangeDataExtensionPack(logger, ranges, checkoutPath) { if (ranges === void 0) { return void 0; } @@ -110541,27 +110963,10 @@ dataExtensions: - pr-diff-range.yml ` ); - const header = ` -extensions: - - addsTo: - pack: codeql/util - extensible: restrictAlertsTo - checkPresence: false - data: -`; - let data = ranges.map( - (range) => ( - // Using yaml.dump() with `forceQuotes: true` ensures that all special - // characters are escaped, and that the path is always rendered as a - // quoted string on a single line. - ` - [${dump(range.path, { forceQuotes: true }).trim()}, ${range.startLine}, ${range.endLine}] -` - ) - ).join(""); - if (!data) { - data = ' - ["", 0, 0]\n'; - } - const extensionContents = header + data; + const extensionContents = diffRangeExtensionPackContents( + ranges, + checkoutPath + ); const extensionFilePath = path12.join(diffRangeDir, "pr-diff-range.yml"); fs12.writeFileSync(extensionFilePath, extensionContents); logger.debug( @@ -110915,7 +111320,7 @@ async function uploadBundledDatabase(repositoryNwo, language, commitOid, bundled // src/status-report.ts var os4 = __toESM(require("os")); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); function isFirstPartyAnalysis(actionName) { if (actionName !== "upload-sarif" /* UploadSarif */) { return true; @@ -110931,12 +111336,12 @@ function getActionsStatus(error3, otherFailureCause) { } function setJobStatusIfUnsuccessful(actionStatus) { if (actionStatus === "user-error") { - core12.exportVariable( + core13.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); } else if (actionStatus === "failure" || actionStatus === "aborted") { - core12.exportVariable( + core13.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_FAILURE" /* FailureStatus */ ); @@ -110955,14 +111360,14 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi let workflowStartedAt = process.env["CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */]; if (workflowStartedAt === void 0) { workflowStartedAt = actionStartedAt.toISOString(); - core12.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); + core13.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); const codeQlCliVersion = getCachedCodeQlVersion(); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { - core12.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); + core13.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); } const isSteadyStateDefaultSetupRun = process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true"; const statusReport = { @@ -111045,9 +111450,9 @@ var INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the API endpo async function sendStatusReport(statusReport) { setJobStatusIfUnsuccessful(statusReport.status); const statusReportJSON = JSON.stringify(statusReport); - core12.debug(`Sending status report: ${statusReportJSON}`); + core13.debug(`Sending status report: ${statusReportJSON}`); if (isInTestMode()) { - core12.debug("In test mode. Status reports are not uploaded."); + core13.debug("In test mode. Status reports are not uploaded."); return; } const nwo = getRepositoryNwo(); @@ -111067,28 +111472,28 @@ async function sendStatusReport(statusReport) { switch (httpError.status) { case 403: if (getWorkflowEventName() === "push" && process.env["GITHUB_ACTOR"] === "dependabot[bot]") { - core12.warning( + core13.warning( `Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading CodeQL results requires write access. To use CodeQL with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. See ${"https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push" /* SCANNING_ON_PUSH */} for more information on how to configure these events.` ); } else { - core12.warning( + core13.warning( `This run of the CodeQL Action does not have permission to access the CodeQL Action API endpoints. This could be because the Action is running on a pull request from a fork. If not, please ensure the workflow has at least the 'security-events: read' permission. Details: ${httpError.message}` ); } return; case 404: - core12.warning(httpError.message); + core13.warning(httpError.message); return; case 422: if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { - core12.debug(INCOMPATIBLE_MSG); + core13.debug(INCOMPATIBLE_MSG); } else { - core12.debug(OUT_OF_DATE_MSG); + core13.debug(OUT_OF_DATE_MSG); } return; } } - core12.warning( + core13.warning( `An unexpected error occurred when sending a status report: ${getErrorMessage( e )}` @@ -111125,7 +111530,7 @@ var fs16 = __toESM(require("fs")); var path14 = __toESM(require("path")); var url = __toESM(require("url")); var import_zlib = __toESM(require("zlib")); -var core14 = __toESM(require_core()); +var core15 = __toESM(require_core()); var jsonschema2 = __toESM(require_lib2()); // src/fingerprints.ts @@ -112251,7 +112656,7 @@ async function addFingerprints(sarifLog, sourceRoot, logger) { } // src/init.ts -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); var toolrunner4 = __toESM(require_toolrunner()); var github2 = __toESM(require_github()); var io6 = __toESM(require_io()); @@ -112395,7 +112800,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo logger.warning( `Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}` ); - core14.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); + core15.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); } return combineSarifFiles(sarifFiles, logger); } @@ -112494,13 +112899,13 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) { if (httpError !== void 0) { switch (httpError.status) { case 403: - core14.warning(httpError.message || GENERIC_403_MSG); + core15.warning(httpError.message || GENERIC_403_MSG); break; case 404: - core14.warning(httpError.message || GENERIC_404_MSG); + core15.warning(httpError.message || GENERIC_404_MSG); break; default: - core14.warning(httpError.message); + core15.warning(httpError.message); break; } } @@ -112887,7 +113292,7 @@ function validateUniqueCategory(sarifLog, sentinelPrefix) { `Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per tool/category. The easiest fix is to specify a unique value for the \`category\` input. If .runs[].automationDetails.id is specified in the sarif file, that will take precedence over your configured \`category\`. Category: (${id ? id : "none"}) Tool: (${tool ? tool : "none"})` ); } - core14.exportVariable(sentinelEnvVar, sentinelEnvVar); + core15.exportVariable(sentinelEnvVar, sentinelEnvVar); } } function sanitize(str2) { @@ -112901,7 +113306,6 @@ function filterAlertsByDiffRange(logger, sarifLog) { if (sarifLog.runs === void 0) { return sarifLog; } - const checkoutPath = getRequiredInput("checkout_path"); for (const run2 of sarifLog.runs) { if (run2.results) { run2.results = run2.results.filter((result) => { @@ -112915,9 +113319,8 @@ function filterAlertsByDiffRange(logger, sarifLog) { if (!locationUri || locationStartLine === void 0) { return false; } - const locationPath = path14.join(checkoutPath, locationUri).replaceAll(path14.sep, "/"); return diffRanges.some( - (range) => range.path === locationPath && (range.startLine <= locationStartLine && range.endLine >= locationStartLine || range.startLine === 0 && range.endLine === 0) + (range) => range.path === locationUri && (range.startLine <= locationStartLine && range.endLine >= locationStartLine || range.startLine === 0 && range.endLine === 0) ); }); }); @@ -113104,7 +113507,7 @@ async function run(startedAt2) { } const apiDetails = getApiDetails(); const outputDir = getRequiredInput("output"); - core15.exportVariable("CODEQL_ACTION_SARIF_RESULTS_OUTPUT_DIR" /* SARIF_RESULTS_OUTPUT_DIR */, outputDir); + core16.exportVariable("CODEQL_ACTION_SARIF_RESULTS_OUTPUT_DIR" /* SARIF_RESULTS_OUTPUT_DIR */, outputDir); const threads = getThreadsFlag( getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger @@ -113161,8 +113564,8 @@ async function run(startedAt2) { for (const language of config.languages) { dbLocations[language] = getCodeQLDatabasePath(config, language); } - core15.setOutput("db-locations", dbLocations); - core15.setOutput("sarif-output", import_path4.default.resolve(outputDir)); + core16.setOutput("db-locations", dbLocations); + core16.setOutput("sarif-output", import_path4.default.resolve(outputDir)); const uploadKind = getUploadValue( getOptionalInput("upload") ); @@ -113179,13 +113582,13 @@ async function run(startedAt2) { getOptionalInput("post-processed-sarif-path") ); if (uploadResults["code-scanning" /* CodeScanning */] !== void 0) { - core15.setOutput( + core16.setOutput( "sarif-id", uploadResults["code-scanning" /* CodeScanning */].sarifID ); } if (uploadResults["code-quality" /* CodeQuality */] !== void 0) { - core15.setOutput( + core16.setOutput( "quality-sarif-id", uploadResults["code-quality" /* CodeQuality */].sarifID ); @@ -113228,15 +113631,15 @@ async function run(startedAt2) { ); } if (getOptionalInput("expect-error") === "true") { - core15.setFailed( + core16.setFailed( `expect-error input was set to true but no error was thrown.` ); } - core15.exportVariable("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */, "true"); + core16.exportVariable("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */, "true"); } catch (unwrappedError) { const error3 = wrapError(unwrappedError); if (getOptionalInput("expect-error") !== "true" || hasBadExpectErrorInput()) { - core15.setFailed(error3.message); + core16.setFailed(error3.message); } await sendStatusReport2( startedAt2, @@ -113307,7 +113710,7 @@ async function runWrapper() { try { await runPromise; } catch (error3) { - core15.setFailed(`analyze action failed: ${getErrorMessage(error3)}`); + core16.setFailed(`analyze action failed: ${getErrorMessage(error3)}`); await sendUnhandledErrorStatusReport( "finish" /* Analyze */, startedAt, diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 1564b1662b..3c227f3df7 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable7; + exports2.exportVariable = exportVariable8; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable7(name, val) { + function exportVariable8(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -48640,7 +48640,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -48652,23 +48652,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core14.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core15.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core14.debug(`implicitDescendants '${result.implicitDescendants}'`); + core15.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core14.debug(`matchDirectories '${result.matchDirectories}'`); + core15.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core14.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core15.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core14.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core15.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -50296,7 +50296,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs7 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path7 = __importStar2(require("path")); @@ -50349,7 +50349,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core14.debug(`Search path '${searchPath}'`); + core15.debug(`Search path '${searchPath}'`); try { yield __await2(fs7.promises.lstat(searchPath)); } catch (err) { @@ -50424,7 +50424,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core14.debug(`Broken symlink '${item.path}'`); + core15.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -50440,7 +50440,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core14.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core15.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -50543,7 +50543,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles; var crypto2 = __importStar2(require("crypto")); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs7 = __importStar2(require("fs")); var stream = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -50552,7 +50552,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core14.info : core14.debug; + const writeDelegate = verbose ? core15.info : core15.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -51943,7 +51943,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var exec = __importStar2(require_exec()); var glob = __importStar2(require_glob()); var io5 = __importStar2(require_io()); @@ -51994,7 +51994,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path7.relative(workspace, file).replace(new RegExp(`\\${path7.sep}`, "g"), "/"); - core14.debug(`Matched: ${relativeFile}`); + core15.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -52022,7 +52022,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core14.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core15.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -52033,10 +52033,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core14.debug(err.message); + core15.debug(err.message); } versionOutput = versionOutput.trim(); - core14.debug(versionOutput); + core15.debug(versionOutput); return versionOutput; }); } @@ -52044,7 +52044,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core14.debug(`zstd version: ${version}`); + core15.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -61827,44 +61827,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -61872,63 +61872,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61937,16 +61937,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61955,83 +61955,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62045,190 +62052,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -62238,290 +62454,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; + } + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; + } + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function lt(t2, e2, i2) { + return pt(t2, e2, i2); } - function H(t2, e2, n2) { - let i2; + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62530,172 +62781,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } + } + return i2; + } + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return s2; + return i2; } - function ot(t2) { + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -91700,7 +92084,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -91742,7 +92126,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core15.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91799,14 +92183,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core14.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core15.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core14.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core15.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -91891,7 +92275,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -91949,9 +92333,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core14.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core15.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core14.debug(`${name} - Error is not retryable`); + core15.debug(`${name} - Error is not retryable`); break; } yield sleep(delay); @@ -92210,7 +92594,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -92248,7 +92632,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core14.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core15.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -92282,7 +92666,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core15.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -92332,7 +92716,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core14.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core15.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -92343,7 +92727,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core14.debug("Unable to validate download, no Content-Length header"); + core15.debug("Unable to validate download, no Content-Length header"); } }); } @@ -92461,7 +92845,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core14.debug("Unable to determine content length, downloading file with http-client..."); + core15.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -92551,7 +92935,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -92571,9 +92955,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core14.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core15.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -92609,12 +92993,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Download concurrency: ${result.downloadConcurrency}`); - core14.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core14.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core14.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core14.debug(`Lookup only: ${result.lookupOnly}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Download concurrency: ${result.downloadConcurrency}`); + core15.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core15.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core15.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core15.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -92808,7 +93192,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache4; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs7 = __importStar2(require("fs")); @@ -92826,7 +93210,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url = `${baseUrl}_apis/artifactcache/${resource}`; - core14.debug(`Resource Url: ${url}`); + core15.debug(`Resource Url: ${url}`); return url; } function createAcceptHeader(type2, apiVersion) { @@ -92854,7 +93238,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core14.isDebug()) { + if (core15.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -92867,9 +93251,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core14.setSecret(cacheDownloadUrl); - core14.debug(`Cache Result:`); - core14.debug(JSON.stringify(cacheResult)); + core15.setSecret(cacheDownloadUrl); + core15.debug(`Cache Result:`); + core15.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -92883,10 +93267,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core14.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core15.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core14.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core15.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -92929,7 +93313,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core14.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core15.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -92951,7 +93335,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core14.debug("Awaiting all uploads"); + core15.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -92994,16 +93378,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core14.debug("Upload cache"); + core15.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core14.debug("Commiting cache"); + core15.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core15.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core14.info("Cache saved successfully"); + core15.info("Cache saved successfully"); } }); } @@ -98486,7 +98870,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache4; exports2.saveCache = saveCache4; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var path7 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -98545,7 +98929,7 @@ var require_cache5 = __commonJS({ function restoreCache4(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -98560,8 +98944,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98579,19 +98963,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path7.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -98599,16 +98983,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98619,8 +99003,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98638,30 +99022,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core14.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core15.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core14.info(`Cache hit for restore-key: ${response.matchedKey}`); + core15.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core14.info(`Cache hit for: ${response.matchedKey}`); + core15.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path7.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive path: ${archivePath}`); - core14.debug(`Starting download of archive to: ${archivePath}`); + core15.debug(`Archive path: ${archivePath}`); + core15.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core14.isDebug()) { + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -98669,9 +99053,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -98680,7 +99064,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98689,7 +99073,7 @@ var require_cache5 = __commonJS({ function saveCache4(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -98707,26 +99091,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path7.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -98739,26 +99123,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core14.debug(`Saving Cache (ID: ${cacheId})`); + core15.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -98771,23 +99155,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path7.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -98798,16 +99182,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core14.warning(`Cache reservation failed: ${response.message}`); + core15.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core14.debug(`Failed to reserve cache: ${error3}`); + core15.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core14.debug(`Attempting to upload cache located at: ${archivePath}`); + core15.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -98815,7 +99199,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core14.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core15.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -98828,21 +99212,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core14.warning(typedError.message); + core15.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99069,7 +99453,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99092,10 +99476,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core14.info(err.message); + core15.info(err.message); } const seconds = this.getSleepAmount(); - core14.info(`Waiting ${seconds} seconds before trying again`); + core15.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99198,7 +99582,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var io5 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs7 = __importStar2(require("fs")); @@ -99227,8 +99611,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path7.join(_getTempDirectory(), crypto2.randomUUID()); yield io5.mkdirP(path7.dirname(dest)); - core14.debug(`Downloading ${url}`); - core14.debug(`Destination ${dest}`); + core15.debug(`Downloading ${url}`); + core15.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99254,7 +99638,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99263,7 +99647,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core14.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core15.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream.pipeline); @@ -99272,16 +99656,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs7.createWriteStream(dest)); - core14.debug("download complete"); + core15.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core14.debug("download failed"); + core15.debug("download failed"); try { yield io5.rmRF(dest); } catch (err) { - core14.debug(`Failed to delete '${dest}'. ${err.message}`); + core15.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99296,7 +99680,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core14.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core15.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core14.debug("Checking tar --version"); + core15.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99359,7 +99743,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core14.debug(versionOutput.trim()); + core15.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99367,7 +99751,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core14.isDebug() && !flags.includes("v")) { + if (core15.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99398,7 +99782,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core14.isDebug()) { + if (core15.isDebug()) { args.push("-v"); } const xarPath = yield io5.which("xar", true); @@ -99441,7 +99825,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core14.debug(`Using pwsh at path: ${pwshPath}`); + core15.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99461,7 +99845,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io5.which("powershell", true); - core14.debug(`Using powershell at path: ${powershellPath}`); + core15.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99470,7 +99854,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io5.which("unzip", true); const args = [file]; - if (!core14.isDebug()) { + if (!core15.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99481,8 +99865,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch}`); - core14.debug(`source dir: ${sourceDir}`); + core15.debug(`Caching tool ${tool} ${version} ${arch}`); + core15.debug(`source dir: ${sourceDir}`); if (!fs7.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99499,14 +99883,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch}`); - core14.debug(`source file: ${sourceFile}`); + core15.debug(`Caching tool ${tool} ${version} ${arch}`); + core15.debug(`source file: ${sourceFile}`); if (!fs7.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch); const destPath = path7.join(destFolder, targetFile); - core14.debug(`destination file ${destPath}`); + core15.debug(`destination file ${destPath}`); yield io5.cp(sourceFile, destPath); _completeToolPath(tool, version, arch); return destFolder; @@ -99529,12 +99913,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path7.join(_getCacheDirectory(), toolName, versionSpec, arch); - core14.debug(`checking cache: ${cachePath}`); + core15.debug(`checking cache: ${cachePath}`); if (fs7.existsSync(cachePath) && fs7.existsSync(`${cachePath}.complete`)) { - core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); toolPath = cachePath; } else { - core14.debug("not found"); + core15.debug("not found"); } } return toolPath; @@ -99563,7 +99947,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99584,7 +99968,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core14.debug("Invalid json"); + core15.debug("Invalid json"); } } return releases; @@ -99608,7 +99992,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path7.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); - core14.debug(`destination ${folderPath}`); + core15.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io5.rmRF(folderPath); yield io5.rmRF(markerPath); @@ -99620,18 +100004,18 @@ var require_tool_cache = __commonJS({ const folderPath = path7.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); const markerPath = `${folderPath}.complete`; fs7.writeFileSync(markerPath, ""); - core14.debug("finished caching tool"); + core15.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core14.debug(`isExplicit: ${c}`); + core15.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core14.debug(`explicit? ${valid3}`); + core15.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core14.debug(`evaluating ${versions.length} versions`); + core15.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -99647,9 +100031,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core14.debug(`matched: ${version}`); + core15.debug(`matched: ${version}`); } else { - core14.debug("match not found"); + core15.debug("match not found"); } return version; } @@ -100225,7 +100609,7 @@ var require_follow_redirects = __commonJS({ }); // src/autobuild-action.ts -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); // src/actions-util.ts var fs = __toESM(require("fs")); @@ -103117,7 +103501,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -103410,12 +103794,12 @@ async function getAnalysisKey() { } // src/autobuild.ts -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); // src/codeql.ts var fs6 = __toESM(require("fs")); var path6 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -103663,6 +104047,7 @@ function wrapCliConfigurationError(cliError) { // src/config-utils.ts var fs4 = __toESM(require("fs")); var path4 = __toESM(require("path")); +var core9 = __toESM(require_core()); // src/analyses.ts var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => { @@ -103719,8 +104104,8 @@ var path3 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.24.3"; -var cliVersion = "2.24.3"; +var bundleVersion = "codeql-bundle-v2.25.0"; +var cliVersion = "2.25.0"; // src/overlay/index.ts var fs2 = __toESM(require("fs")); @@ -103894,6 +104279,7 @@ async function isAnalyzingDefaultBranch() { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -104043,6 +104429,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -104073,6 +104464,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -104083,16 +104479,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -104108,15 +104494,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -104500,6 +104902,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -104508,6 +104911,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -104570,7 +104974,7 @@ var toolcache = __toESM(require_tool_cache()); var semver6 = __toESM(require_semver2()); // src/tools-download.ts -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -104628,7 +105032,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function getCodeQL(cmd) { if (cachedCodeQL === void 0) { cachedCodeQL = await getCodeQLForCmd(cmd, true); @@ -104924,17 +105327,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -105083,12 +105482,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core10.warning( + core11.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core10.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -105249,16 +105648,16 @@ async function setupCppAutobuild(codeql, logger) { logger.info( `Disabling ${featureName} as we are on a self-hosted runner.${getWorkflowEventName() !== "dynamic" ? ` To override this, set the ${envVar} environment variable to 'true' in your workflow. See ${"https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow" /* DEFINE_ENV_VARIABLES */} for more information.` : ""}` ); - core11.exportVariable(envVar, "false"); + core12.exportVariable(envVar, "false"); } else { logger.info( `Enabling ${featureName}. This can be disabled by setting the ${envVar} environment variable to 'false'. See ${"https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow" /* DEFINE_ENV_VARIABLES */} for more information.` ); - core11.exportVariable(envVar, "true"); + core12.exportVariable(envVar, "true"); } } else { logger.info(`Disabling ${featureName}.`); - core11.exportVariable(envVar, "false"); + core12.exportVariable(envVar, "false"); } } async function runAutobuild(config, language, logger) { @@ -105273,14 +105672,14 @@ async function runAutobuild(config, language, logger) { await codeQL.runAutobuild(config, language); } if (language === "go" /* go */) { - core11.exportVariable("CODEQL_ACTION_DID_AUTOBUILD_GOLANG" /* DID_AUTOBUILD_GOLANG */, "true"); + core12.exportVariable("CODEQL_ACTION_DID_AUTOBUILD_GOLANG" /* DID_AUTOBUILD_GOLANG */, "true"); } logger.endGroup(); } // src/status-report.ts var os = __toESM(require("os")); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); function isFirstPartyAnalysis(actionName) { if (actionName !== "upload-sarif" /* UploadSarif */) { return true; @@ -105296,12 +105695,12 @@ function getActionsStatus(error3, otherFailureCause) { } function setJobStatusIfUnsuccessful(actionStatus) { if (actionStatus === "user-error") { - core12.exportVariable( + core13.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); } else if (actionStatus === "failure" || actionStatus === "aborted") { - core12.exportVariable( + core13.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_FAILURE" /* FailureStatus */ ); @@ -105320,14 +105719,14 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi let workflowStartedAt = process.env["CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */]; if (workflowStartedAt === void 0) { workflowStartedAt = actionStartedAt.toISOString(); - core12.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); + core13.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); const codeQlCliVersion = getCachedCodeQlVersion(); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { - core12.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); + core13.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); } const isSteadyStateDefaultSetupRun = process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true"; const statusReport = { @@ -105410,9 +105809,9 @@ var INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the API endpo async function sendStatusReport(statusReport) { setJobStatusIfUnsuccessful(statusReport.status); const statusReportJSON = JSON.stringify(statusReport); - core12.debug(`Sending status report: ${statusReportJSON}`); + core13.debug(`Sending status report: ${statusReportJSON}`); if (isInTestMode()) { - core12.debug("In test mode. Status reports are not uploaded."); + core13.debug("In test mode. Status reports are not uploaded."); return; } const nwo = getRepositoryNwo(); @@ -105432,28 +105831,28 @@ async function sendStatusReport(statusReport) { switch (httpError.status) { case 403: if (getWorkflowEventName() === "push" && process.env["GITHUB_ACTOR"] === "dependabot[bot]") { - core12.warning( + core13.warning( `Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading CodeQL results requires write access. To use CodeQL with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. See ${"https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push" /* SCANNING_ON_PUSH */} for more information on how to configure these events.` ); } else { - core12.warning( + core13.warning( `This run of the CodeQL Action does not have permission to access the CodeQL Action API endpoints. This could be because the Action is running on a pull request from a fork. If not, please ensure the workflow has at least the 'security-events: read' permission. Details: ${httpError.message}` ); } return; case 404: - core12.warning(httpError.message); + core13.warning(httpError.message); return; case 422: if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { - core12.debug(INCOMPATIBLE_MSG); + core13.debug(INCOMPATIBLE_MSG); } else { - core12.debug(OUT_OF_DATE_MSG); + core13.debug(OUT_OF_DATE_MSG); } return; } } - core12.warning( + core13.warning( `An unexpected error occurred when sending a status report: ${getErrorMessage( e )}` @@ -105552,7 +105951,7 @@ async function run(startedAt) { await endTracingForCluster(codeql, config, logger); } catch (unwrappedError) { const error3 = wrapError(unwrappedError); - core13.setFailed( + core14.setFailed( `We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps. ${error3.message}` ); await sendCompletedStatusReport( @@ -105565,7 +105964,7 @@ async function run(startedAt) { ); return; } - core13.exportVariable("CODEQL_ACTION_AUTOBUILD_DID_COMPLETE_SUCCESSFULLY" /* AUTOBUILD_DID_COMPLETE_SUCCESSFULLY */, "true"); + core14.exportVariable("CODEQL_ACTION_AUTOBUILD_DID_COMPLETE_SUCCESSFULLY" /* AUTOBUILD_DID_COMPLETE_SUCCESSFULLY */, "true"); await sendCompletedStatusReport(config, logger, startedAt, languages ?? []); } async function runWrapper() { @@ -105574,7 +105973,7 @@ async function runWrapper() { try { await run(startedAt); } catch (error3) { - core13.setFailed(`autobuild action failed. ${getErrorMessage(error3)}`); + core14.setFailed(`autobuild action failed. ${getErrorMessage(error3)}`); await sendUnhandledErrorStatusReport( "autobuild" /* Autobuild */, startedAt, diff --git a/lib/defaults.json b/lib/defaults.json index 9b6ec84bd4..c327217afe 100644 --- a/lib/defaults.json +++ b/lib/defaults.json @@ -1,6 +1,6 @@ { - "bundleVersion": "codeql-bundle-v2.24.3", - "cliVersion": "2.24.3", - "priorBundleVersion": "codeql-bundle-v2.24.2", - "priorCliVersion": "2.24.2" + "bundleVersion": "codeql-bundle-v2.25.0", + "cliVersion": "2.25.0", + "priorBundleVersion": "codeql-bundle-v2.24.3", + "priorCliVersion": "2.24.3" } diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 5504bfece0..5023830c49 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable10; + exports2.exportVariable = exportVariable11; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable10(name, val) { + function exportVariable11(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -48640,7 +48640,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -48652,23 +48652,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core18.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core19.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core18.debug(`implicitDescendants '${result.implicitDescendants}'`); + core19.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core18.debug(`matchDirectories '${result.matchDirectories}'`); + core19.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core18.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core19.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core18.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core19.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -50296,7 +50296,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var fs20 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path19 = __importStar2(require("path")); @@ -50349,7 +50349,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core18.debug(`Search path '${searchPath}'`); + core19.debug(`Search path '${searchPath}'`); try { yield __await2(fs20.promises.lstat(searchPath)); } catch (err) { @@ -50424,7 +50424,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core18.debug(`Broken symlink '${item.path}'`); + core19.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -50440,7 +50440,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core18.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core19.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -50543,7 +50543,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles2; var crypto2 = __importStar2(require("crypto")); - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var fs20 = __importStar2(require("fs")); var stream2 = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -50552,7 +50552,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core18.info : core18.debug; + const writeDelegate = verbose ? core19.info : core19.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -51943,7 +51943,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var exec3 = __importStar2(require_exec()); var glob2 = __importStar2(require_glob()); var io7 = __importStar2(require_io()); @@ -51994,7 +51994,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path19.relative(workspace, file).replace(new RegExp(`\\${path19.sep}`, "g"), "/"); - core18.debug(`Matched: ${relativeFile}`); + core19.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -52022,7 +52022,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core18.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core19.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec3.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -52033,10 +52033,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core18.debug(err.message); + core19.debug(err.message); } versionOutput = versionOutput.trim(); - core18.debug(versionOutput); + core19.debug(versionOutput); return versionOutput; }); } @@ -52044,7 +52044,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core18.debug(`zstd version: ${version}`); + core19.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -61827,44 +61827,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -61872,63 +61872,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); - } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); + } + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61937,16 +61937,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61955,83 +61955,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62045,190 +62052,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _2(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _2(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _2(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _2(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _2 = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _2), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -62238,290 +62454,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; - } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; + } else { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + } + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; + } + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function lt(t2, e2, i2) { + return pt(t2, e2, i2); } - function H(t2, e2, n2) { - let i2; + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62530,172 +62781,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } + } + return i2; + } + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return s2; + return i2; } - function ot(t2) { + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -91700,7 +92084,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -91742,7 +92126,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core18.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core19.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91799,14 +92183,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core18.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core19.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core18.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core19.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -91891,7 +92275,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -91949,9 +92333,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core18.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core19.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core18.debug(`${name} - Error is not retryable`); + core19.debug(`${name} - Error is not retryable`); break; } yield sleep(delay2); @@ -92210,7 +92594,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -92248,7 +92632,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core18.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core19.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -92282,7 +92666,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core18.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core19.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -92332,7 +92716,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core18.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core19.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -92343,7 +92727,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core18.debug("Unable to validate download, no Content-Length header"); + core19.debug("Unable to validate download, no Content-Length header"); } }); } @@ -92461,7 +92845,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core18.debug("Unable to determine content length, downloading file with http-client..."); + core19.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -92551,7 +92935,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -92571,9 +92955,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core18.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core18.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core18.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core19.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core19.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core19.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -92609,12 +92993,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core18.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core18.debug(`Download concurrency: ${result.downloadConcurrency}`); - core18.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core18.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core18.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core18.debug(`Lookup only: ${result.lookupOnly}`); + core19.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core19.debug(`Download concurrency: ${result.downloadConcurrency}`); + core19.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core19.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core19.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core19.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -92808,7 +93192,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache5; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs20 = __importStar2(require("fs")); @@ -92826,7 +93210,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url2 = `${baseUrl}_apis/artifactcache/${resource}`; - core18.debug(`Resource Url: ${url2}`); + core19.debug(`Resource Url: ${url2}`); return url2; } function createAcceptHeader(type2, apiVersion) { @@ -92854,7 +93238,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core18.isDebug()) { + if (core19.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -92867,9 +93251,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core18.setSecret(cacheDownloadUrl); - core18.debug(`Cache Result:`); - core18.debug(JSON.stringify(cacheResult)); + core19.setSecret(cacheDownloadUrl); + core19.debug(`Cache Result:`); + core19.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -92883,10 +93267,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core18.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core19.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core18.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core19.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -92929,7 +93313,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core18.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core19.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -92951,7 +93335,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core18.debug("Awaiting all uploads"); + core19.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -92994,16 +93378,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core18.debug("Upload cache"); + core19.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core18.debug("Commiting cache"); + core19.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core18.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core19.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core18.info("Cache saved successfully"); + core19.info("Cache saved successfully"); } }); } @@ -98486,7 +98870,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache5; exports2.saveCache = saveCache5; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var path19 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -98545,7 +98929,7 @@ var require_cache5 = __commonJS({ function restoreCache5(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core18.debug(`Cache service version: ${cacheServiceVersion}`); + core19.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -98560,8 +98944,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core18.debug("Resolved Keys:"); - core18.debug(JSON.stringify(keys)); + core19.debug("Resolved Keys:"); + core19.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98579,19 +98963,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core18.info("Lookup only - skipping download"); + core19.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path19.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core18.debug(`Archive Path: ${archivePath}`); + core19.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core18.isDebug()) { + if (core19.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core18.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core19.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core18.info("Cache restored successfully"); + core19.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -98599,16 +98983,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core18.error(`Failed to restore: ${error3.message}`); + core19.error(`Failed to restore: ${error3.message}`); } else { - core18.warning(`Failed to restore: ${error3.message}`); + core19.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core18.debug(`Failed to delete archive: ${error3}`); + core19.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98619,8 +99003,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core18.debug("Resolved Keys:"); - core18.debug(JSON.stringify(keys)); + core19.debug("Resolved Keys:"); + core19.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98638,30 +99022,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core18.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core19.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core18.info(`Cache hit for restore-key: ${response.matchedKey}`); + core19.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core18.info(`Cache hit for: ${response.matchedKey}`); + core19.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core18.info("Lookup only - skipping download"); + core19.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path19.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core18.debug(`Archive path: ${archivePath}`); - core18.debug(`Starting download of archive to: ${archivePath}`); + core19.debug(`Archive path: ${archivePath}`); + core19.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core18.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core18.isDebug()) { + core19.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core19.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core18.info("Cache restored successfully"); + core19.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -98669,9 +99053,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core18.error(`Failed to restore: ${error3.message}`); + core19.error(`Failed to restore: ${error3.message}`); } else { - core18.warning(`Failed to restore: ${error3.message}`); + core19.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -98680,7 +99064,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core18.debug(`Failed to delete archive: ${error3}`); + core19.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98689,7 +99073,7 @@ var require_cache5 = __commonJS({ function saveCache5(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core18.debug(`Cache service version: ${cacheServiceVersion}`); + core19.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -98707,26 +99091,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core18.debug("Cache Paths:"); - core18.debug(`${JSON.stringify(cachePaths)}`); + core19.debug("Cache Paths:"); + core19.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path19.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core18.debug(`Archive Path: ${archivePath}`); + core19.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core18.isDebug()) { + if (core19.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core18.debug(`File Size: ${archiveFileSize}`); + core19.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core18.debug("Reserving Cache"); + core19.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -98739,26 +99123,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core18.debug(`Saving Cache (ID: ${cacheId})`); + core19.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core18.info(`Failed to save: ${typedError.message}`); + core19.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core18.error(`Failed to save: ${typedError.message}`); + core19.error(`Failed to save: ${typedError.message}`); } else { - core18.warning(`Failed to save: ${typedError.message}`); + core19.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core18.debug(`Failed to delete archive: ${error3}`); + core19.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -98771,23 +99155,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core18.debug("Cache Paths:"); - core18.debug(`${JSON.stringify(cachePaths)}`); + core19.debug("Cache Paths:"); + core19.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path19.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core18.debug(`Archive Path: ${archivePath}`); + core19.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core18.isDebug()) { + if (core19.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core18.debug(`File Size: ${archiveFileSize}`); + core19.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core18.debug("Reserving Cache"); + core19.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -98798,16 +99182,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core18.warning(`Cache reservation failed: ${response.message}`); + core19.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core18.debug(`Failed to reserve cache: ${error3}`); + core19.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core18.debug(`Attempting to upload cache located at: ${archivePath}`); + core19.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -98815,7 +99199,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core18.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core19.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -98828,21 +99212,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core18.info(`Failed to save: ${typedError.message}`); + core19.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core18.warning(typedError.message); + core19.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core18.error(`Failed to save: ${typedError.message}`); + core19.error(`Failed to save: ${typedError.message}`); } else { - core18.warning(`Failed to save: ${typedError.message}`); + core19.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core18.debug(`Failed to delete archive: ${error3}`); + core19.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99069,7 +99453,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99092,10 +99476,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core18.info(err.message); + core19.info(err.message); } const seconds = this.getSleepAmount(); - core18.info(`Waiting ${seconds} seconds before trying again`); + core19.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99198,7 +99582,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var io7 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs20 = __importStar2(require("fs")); @@ -99227,8 +99611,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path19.join(_getTempDirectory(), crypto2.randomUUID()); yield io7.mkdirP(path19.dirname(dest)); - core18.debug(`Downloading ${url2}`); - core18.debug(`Destination ${dest}`); + core19.debug(`Downloading ${url2}`); + core19.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99254,7 +99638,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core18.debug("set auth"); + core19.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99263,7 +99647,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url2, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core18.debug(`Failed to download from "${url2}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core19.debug(`Failed to download from "${url2}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream2.pipeline); @@ -99272,16 +99656,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs20.createWriteStream(dest)); - core18.debug("download complete"); + core19.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core18.debug("download failed"); + core19.debug("download failed"); try { yield io7.rmRF(dest); } catch (err) { - core18.debug(`Failed to delete '${dest}'. ${err.message}`); + core19.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99296,7 +99680,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core18.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core19.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core18.debug("Checking tar --version"); + core19.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99359,7 +99743,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core18.debug(versionOutput.trim()); + core19.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99367,7 +99751,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core18.isDebug() && !flags.includes("v")) { + if (core19.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99398,7 +99782,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core18.isDebug()) { + if (core19.isDebug()) { args.push("-v"); } const xarPath = yield io7.which("xar", true); @@ -99441,7 +99825,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core18.debug(`Using pwsh at path: ${pwshPath}`); + core19.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99461,7 +99845,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io7.which("powershell", true); - core18.debug(`Using powershell at path: ${powershellPath}`); + core19.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99470,7 +99854,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io7.which("unzip", true); const args = [file]; - if (!core18.isDebug()) { + if (!core19.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99481,8 +99865,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os4.arch(); - core18.debug(`Caching tool ${tool} ${version} ${arch2}`); - core18.debug(`source dir: ${sourceDir}`); + core19.debug(`Caching tool ${tool} ${version} ${arch2}`); + core19.debug(`source dir: ${sourceDir}`); if (!fs20.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99499,14 +99883,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os4.arch(); - core18.debug(`Caching tool ${tool} ${version} ${arch2}`); - core18.debug(`source file: ${sourceFile}`); + core19.debug(`Caching tool ${tool} ${version} ${arch2}`); + core19.debug(`source file: ${sourceFile}`); if (!fs20.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch2); const destPath = path19.join(destFolder, targetFile); - core18.debug(`destination file ${destPath}`); + core19.debug(`destination file ${destPath}`); yield io7.cp(sourceFile, destPath); _completeToolPath(tool, version, arch2); return destFolder; @@ -99529,12 +99913,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path19.join(_getCacheDirectory(), toolName, versionSpec, arch2); - core18.debug(`checking cache: ${cachePath}`); + core19.debug(`checking cache: ${cachePath}`); if (fs20.existsSync(cachePath) && fs20.existsSync(`${cachePath}.complete`)) { - core18.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); + core19.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); toolPath = cachePath; } else { - core18.debug("not found"); + core19.debug("not found"); } } return toolPath; @@ -99563,7 +99947,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core18.debug("set auth"); + core19.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99584,7 +99968,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core18.debug("Invalid json"); + core19.debug("Invalid json"); } } return releases; @@ -99608,7 +99992,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch2) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path19.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); - core18.debug(`destination ${folderPath}`); + core19.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io7.rmRF(folderPath); yield io7.rmRF(markerPath); @@ -99620,18 +100004,18 @@ var require_tool_cache = __commonJS({ const folderPath = path19.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); const markerPath = `${folderPath}.complete`; fs20.writeFileSync(markerPath, ""); - core18.debug("finished caching tool"); + core19.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core18.debug(`isExplicit: ${c}`); + core19.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core18.debug(`explicit? ${valid3}`); + core19.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core18.debug(`evaluating ${versions.length} versions`); + core19.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -99647,9 +100031,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core18.debug(`matched: ${version}`); + core19.debug(`matched: ${version}`); } else { - core18.debug("match not found"); + core19.debug("match not found"); } return version; } @@ -102331,14 +102715,14 @@ var require_retention = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getExpiration = void 0; var generated_1 = require_generated(); - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); function getExpiration(retentionDays) { if (!retentionDays) { return void 0; } const maxRetentionDays = getRetentionDays(); if (maxRetentionDays && maxRetentionDays < retentionDays) { - core18.warning(`Retention days cannot be greater than the maximum allowed retention set within the repository. Using ${maxRetentionDays} instead.`); + core19.warning(`Retention days cannot be greater than the maximum allowed retention set within the repository. Using ${maxRetentionDays} instead.`); retentionDays = maxRetentionDays; } const expirationDate = /* @__PURE__ */ new Date(); @@ -102676,7 +103060,7 @@ var require_util19 = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.maskSecretUrls = exports2.maskSigUrl = exports2.getBackendIdsFromToken = void 0; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var config_1 = require_config2(); var jwt_decode_1 = __importDefault2(require_jwt_decode_cjs()); var core_1 = require_core(); @@ -102703,8 +103087,8 @@ var require_util19 = __commonJS({ workflowRunBackendId: scopeParts[1], workflowJobRunBackendId: scopeParts[2] }; - core18.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); - core18.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); + core19.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); + core19.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); return ids; } throw InvalidJwtError; @@ -103064,7 +103448,7 @@ var require_blob_upload = __commonJS({ exports2.uploadZipToBlobStorage = void 0; var storage_blob_1 = require_commonjs15(); var config_1 = require_config2(); - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var crypto2 = __importStar2(require("crypto")); var stream2 = __importStar2(require("stream")); var errors_1 = require_errors4(); @@ -103090,9 +103474,9 @@ var require_blob_upload = __commonJS({ const bufferSize = (0, config_1.getUploadChunkSize)(); const blobClient = new storage_blob_1.BlobClient(authenticatedUploadURL); const blockBlobClient = blobClient.getBlockBlobClient(); - core18.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`); + core19.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`); const uploadCallback = (progress) => { - core18.info(`Uploaded bytes ${progress.loadedBytes}`); + core19.info(`Uploaded bytes ${progress.loadedBytes}`); uploadByteCount = progress.loadedBytes; lastProgressTime = Date.now(); }; @@ -103106,7 +103490,7 @@ var require_blob_upload = __commonJS({ const hashStream = crypto2.createHash("sha256"); zipUploadStream.pipe(uploadStream); zipUploadStream.pipe(hashStream).setEncoding("hex"); - core18.info("Beginning upload of artifact content to blob storage"); + core19.info("Beginning upload of artifact content to blob storage"); try { yield Promise.race([ blockBlobClient.uploadStream(uploadStream, bufferSize, maxConcurrency, options), @@ -103120,12 +103504,12 @@ var require_blob_upload = __commonJS({ } finally { abortController.abort(); } - core18.info("Finished uploading artifact content to blob storage!"); + core19.info("Finished uploading artifact content to blob storage!"); hashStream.end(); sha256Hash = hashStream.read(); - core18.info(`SHA256 digest of uploaded artifact zip is ${sha256Hash}`); + core19.info(`SHA256 digest of uploaded artifact zip is ${sha256Hash}`); if (uploadByteCount === 0) { - core18.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`); + core19.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`); } return { uploadSize: uploadByteCount, @@ -109616,8 +110000,8 @@ var require_primordials = __commonJS({ ArrayPrototypeIndexOf(self2, el) { return self2.indexOf(el); }, - ArrayPrototypeJoin(self2, sep5) { - return self2.join(sep5); + ArrayPrototypeJoin(self2, sep4) { + return self2.join(sep4); }, ArrayPrototypeMap(self2, fn) { return self2.map(fn); @@ -121870,7 +122254,7 @@ var require_commonjs23 = __commonJS({ * * @internal */ - constructor(cwd = process.cwd(), pathImpl, sep5, { nocase, childrenCacheSize = 16 * 1024, fs: fs20 = defaultFS } = {}) { + constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs20 = defaultFS } = {}) { this.#fs = fsFromOption(fs20); if (cwd instanceof URL || cwd.startsWith("file://")) { cwd = (0, node_url_1.fileURLToPath)(cwd); @@ -121881,7 +122265,7 @@ var require_commonjs23 = __commonJS({ this.#resolveCache = new ResolveCache(); this.#resolvePosixCache = new ResolveCache(); this.#children = new ChildrenCache(childrenCacheSize); - const split = cwdPath.substring(this.rootPath.length).split(sep5); + const split = cwdPath.substring(this.rootPath.length).split(sep4); if (split.length === 1 && !split[0]) { split.pop(); } @@ -128466,7 +128850,7 @@ var require_zip2 = __commonJS({ var stream2 = __importStar2(require("stream")); var promises_1 = require("fs/promises"); var archiver2 = __importStar2(require_archiver()); - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var config_1 = require_config2(); exports2.DEFAULT_COMPRESSION_LEVEL = 6; var ZipUploadStream = class extends stream2.Transform { @@ -128483,7 +128867,7 @@ var require_zip2 = __commonJS({ exports2.ZipUploadStream = ZipUploadStream; function createZipUploadStream(uploadSpecification_1) { return __awaiter2(this, arguments, void 0, function* (uploadSpecification, compressionLevel = exports2.DEFAULT_COMPRESSION_LEVEL) { - core18.debug(`Creating Artifact archive with compressionLevel: ${compressionLevel}`); + core19.debug(`Creating Artifact archive with compressionLevel: ${compressionLevel}`); const zip = archiver2.create("zip", { highWaterMark: (0, config_1.getUploadChunkSize)(), zlib: { level: compressionLevel } @@ -128507,8 +128891,8 @@ var require_zip2 = __commonJS({ } const bufferSize = (0, config_1.getUploadChunkSize)(); const zipUploadStream = new ZipUploadStream(bufferSize); - core18.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`); - core18.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`); + core19.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`); + core19.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`); zip.pipe(zipUploadStream); zip.finalize(); return zipUploadStream; @@ -128516,24 +128900,24 @@ var require_zip2 = __commonJS({ } exports2.createZipUploadStream = createZipUploadStream; var zipErrorCallback = (error3) => { - core18.error("An error has occurred while creating the zip file for upload"); - core18.info(error3); + core19.error("An error has occurred while creating the zip file for upload"); + core19.info(error3); throw new Error("An error has occurred during zip creation for the artifact"); }; var zipWarningCallback = (error3) => { if (error3.code === "ENOENT") { - core18.warning("ENOENT warning during artifact zip creation. No such file or directory"); - core18.info(error3); + core19.warning("ENOENT warning during artifact zip creation. No such file or directory"); + core19.info(error3); } else { - core18.warning(`A non-blocking warning has occurred during artifact zip creation: ${error3.code}`); - core18.info(error3); + core19.warning(`A non-blocking warning has occurred during artifact zip creation: ${error3.code}`); + core19.info(error3); } }; var zipFinishCallback = () => { - core18.debug("Zip stream for upload has finished."); + core19.debug("Zip stream for upload has finished."); }; var zipEndCallback = () => { - core18.debug("Zip stream for upload has ended."); + core19.debug("Zip stream for upload has ended."); }; } }); @@ -128598,7 +128982,7 @@ var require_upload_artifact = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.uploadArtifact = void 0; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var retention_1 = require_retention(); var path_and_artifact_name_validation_1 = require_path_and_artifact_name_validation(); var artifact_twirp_client_1 = require_artifact_twirp_client2(); @@ -128645,13 +129029,13 @@ var require_upload_artifact = __commonJS({ value: `sha256:${uploadResult.sha256Hash}` }); } - core18.info(`Finalizing artifact upload`); + core19.info(`Finalizing artifact upload`); const finalizeArtifactResp = yield artifactClient.FinalizeArtifact(finalizeArtifactReq); if (!finalizeArtifactResp.ok) { throw new errors_1.InvalidResponseError("FinalizeArtifact: response from backend was not ok"); } const artifactId = BigInt(finalizeArtifactResp.artifactId); - core18.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`); + core19.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`); return { size: uploadResult.uploadSize, digest: uploadResult.sha256Hash, @@ -152132,7 +152516,7 @@ var require_download_artifact = __commonJS({ var crypto2 = __importStar2(require("crypto")); var stream2 = __importStar2(require("stream")); var github4 = __importStar2(require_github2()); - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var httpClient = __importStar2(require_lib()); var unzip_stream_1 = __importDefault2(require_unzip()); var user_agent_1 = require_user_agent2(); @@ -152168,7 +152552,7 @@ var require_download_artifact = __commonJS({ return yield streamExtractExternal(url2, directory); } catch (error3) { retryCount++; - core18.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); + core19.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); yield new Promise((resolve8) => setTimeout(resolve8, 5e3)); } } @@ -152198,7 +152582,7 @@ var require_download_artifact = __commonJS({ extractStream.on("data", () => { timer.refresh(); }).on("error", (error3) => { - core18.debug(`response.message: Artifact download failed: ${error3.message}`); + core19.debug(`response.message: Artifact download failed: ${error3.message}`); clearTimeout(timer); reject(error3); }).pipe(unzip_stream_1.default.Extract({ path: directory })).on("close", () => { @@ -152206,7 +152590,7 @@ var require_download_artifact = __commonJS({ if (hashStream) { hashStream.end(); sha256Digest = hashStream.read(); - core18.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); + core19.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); } resolve8({ sha256Digest: `sha256:${sha256Digest}` }); }).on("error", (error3) => { @@ -152221,7 +152605,7 @@ var require_download_artifact = __commonJS({ const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path); const api = github4.getOctokit(token); let digestMismatch = false; - core18.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`); + core19.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`); const { headers, status } = yield api.rest.actions.downloadArtifact({ owner: repositoryOwner, repo: repositoryName, @@ -152238,16 +152622,16 @@ var require_download_artifact = __commonJS({ if (!location) { throw new Error(`Unable to redirect to artifact download url`); } - core18.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`); + core19.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`); try { - core18.info(`Starting download of artifact to: ${downloadPath}`); + core19.info(`Starting download of artifact to: ${downloadPath}`); const extractResponse = yield streamExtract(location, downloadPath); - core18.info(`Artifact download completed successfully.`); + core19.info(`Artifact download completed successfully.`); if (options === null || options === void 0 ? void 0 : options.expectedHash) { if ((options === null || options === void 0 ? void 0 : options.expectedHash) !== extractResponse.sha256Digest) { digestMismatch = true; - core18.debug(`Computed digest: ${extractResponse.sha256Digest}`); - core18.debug(`Expected digest: ${options.expectedHash}`); + core19.debug(`Computed digest: ${extractResponse.sha256Digest}`); + core19.debug(`Expected digest: ${options.expectedHash}`); } } } catch (error3) { @@ -152274,7 +152658,7 @@ var require_download_artifact = __commonJS({ Are you trying to download from a different run? Try specifying a github-token with \`actions:read\` scope.`); } if (artifacts.length > 1) { - core18.warning("Multiple artifacts found, defaulting to first."); + core19.warning("Multiple artifacts found, defaulting to first."); } const signedReq = { workflowRunBackendId: artifacts[0].workflowRunBackendId, @@ -152282,16 +152666,16 @@ Are you trying to download from a different run? Try specifying a github-token w name: artifacts[0].name }; const { signedUrl } = yield artifactClient.GetSignedArtifactURL(signedReq); - core18.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`); + core19.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`); try { - core18.info(`Starting download of artifact to: ${downloadPath}`); + core19.info(`Starting download of artifact to: ${downloadPath}`); const extractResponse = yield streamExtract(signedUrl, downloadPath); - core18.info(`Artifact download completed successfully.`); + core19.info(`Artifact download completed successfully.`); if (options === null || options === void 0 ? void 0 : options.expectedHash) { if ((options === null || options === void 0 ? void 0 : options.expectedHash) !== extractResponse.sha256Digest) { digestMismatch = true; - core18.debug(`Computed digest: ${extractResponse.sha256Digest}`); - core18.debug(`Expected digest: ${options.expectedHash}`); + core19.debug(`Computed digest: ${extractResponse.sha256Digest}`); + core19.debug(`Expected digest: ${options.expectedHash}`); } } } catch (error3) { @@ -152304,10 +152688,10 @@ Are you trying to download from a different run? Try specifying a github-token w function resolveOrCreateDirectory() { return __awaiter2(this, arguments, void 0, function* (downloadPath = (0, config_1.getGitHubWorkspaceDir)()) { if (!(yield exists(downloadPath))) { - core18.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`); + core19.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`); yield promises_1.default.mkdir(downloadPath, { recursive: true }); } else { - core18.debug(`Artifact destination folder already exists: ${downloadPath}`); + core19.debug(`Artifact destination folder already exists: ${downloadPath}`); } return downloadPath; }); @@ -152348,7 +152732,7 @@ var require_retry_options = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getRetryOptions = void 0; - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var defaultMaxRetryNumber = 5; var defaultExemptStatusCodes = [400, 401, 403, 404, 422]; function getRetryOptions(defaultOptions, retries = defaultMaxRetryNumber, exemptStatusCodes = defaultExemptStatusCodes) { @@ -152363,7 +152747,7 @@ var require_retry_options = __commonJS({ retryOptions.doNotRetry = exemptStatusCodes; } const requestOptions = Object.assign(Object.assign({}, defaultOptions.request), { retries }); - core18.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : "octokit default: [400, 401, 403, 404, 422]"})`); + core19.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : "octokit default: [400, 401, 403, 404, 422]"})`); return [retryOptions, requestOptions]; } exports2.getRetryOptions = getRetryOptions; @@ -152520,7 +152904,7 @@ var require_get_artifact = __commonJS({ exports2.getArtifactInternal = exports2.getArtifactPublic = void 0; var github_1 = require_github2(); var plugin_retry_1 = require_dist_node12(); - var core18 = __importStar2(require_core()); + var core19 = __importStar2(require_core()); var utils_1 = require_utils11(); var retry_options_1 = require_retry_options(); var plugin_request_log_1 = require_dist_node11(); @@ -152558,7 +152942,7 @@ var require_get_artifact = __commonJS({ let artifact2 = getArtifactResp.data.artifacts[0]; if (getArtifactResp.data.artifacts.length > 1) { artifact2 = getArtifactResp.data.artifacts.sort((a, b) => b.id - a.id)[0]; - core18.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.id})`); + core19.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.id})`); } return { artifact: { @@ -152591,7 +152975,7 @@ var require_get_artifact = __commonJS({ let artifact2 = res.artifacts[0]; if (res.artifacts.length > 1) { artifact2 = res.artifacts.sort((a, b) => Number(b.databaseId) - Number(a.databaseId))[0]; - core18.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.databaseId})`); + core19.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.databaseId})`); } return { artifact: { @@ -155699,7 +156083,7 @@ var require_core3 = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable10(name, val) { + function exportVariable11(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -155708,7 +156092,7 @@ var require_core3 = __commonJS({ } (0, command_1.issueCommand)("set-env", { name }, convertedVal); } - exports2.exportVariable = exportVariable10; + exports2.exportVariable = exportVariable11; function setSecret(secret) { (0, command_1.issueCommand)("add-mask", {}, secret); } @@ -157329,7 +157713,7 @@ var require_requestUtils2 = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.retryHttpClientRequest = exports2.retry = void 0; var utils_1 = require_utils13(); - var core18 = __importStar2(require_core3()); + var core19 = __importStar2(require_core3()); var config_variables_1 = require_config_variables(); function retry2(name, operation, customErrorMessages, maxAttempts) { return __awaiter2(this, void 0, void 0, function* () { @@ -157356,13 +157740,13 @@ var require_requestUtils2 = __commonJS({ errorMessage = error3.message; } if (!isRetryable) { - core18.info(`${name} - Error is not retryable`); + core19.info(`${name} - Error is not retryable`); if (response) { (0, utils_1.displayHttpDiagnostics)(response); } break; } - core18.info(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core19.info(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); yield (0, utils_1.sleep)((0, utils_1.getExponentialRetryTimeInMilliseconds)(attempt)); attempt++; } @@ -157446,7 +157830,7 @@ var require_upload_http_client = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadHttpClient = void 0; var fs20 = __importStar2(require("fs")); - var core18 = __importStar2(require_core3()); + var core19 = __importStar2(require_core3()); var tmp = __importStar2(require_tmp_promise()); var stream2 = __importStar2(require("stream")); var utils_1 = require_utils13(); @@ -157511,7 +157895,7 @@ var require_upload_http_client = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const FILE_CONCURRENCY = (0, config_variables_1.getUploadFileConcurrency)(); const MAX_CHUNK_SIZE = (0, config_variables_1.getUploadChunkSize)(); - core18.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`); + core19.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`); const parameters = []; let continueOnError = true; if (options) { @@ -157548,15 +157932,15 @@ var require_upload_http_client = __commonJS({ } const startTime = perf_hooks_1.performance.now(); const uploadFileResult = yield this.uploadFileAsync(index, currentFileParameters); - if (core18.isDebug()) { - core18.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`); + if (core19.isDebug()) { + core19.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`); } uploadFileSize += uploadFileResult.successfulUploadSize; totalFileSize += uploadFileResult.totalSize; if (uploadFileResult.isSuccess === false) { failedItemsToReport.push(currentFileParameters.file); if (!continueOnError) { - core18.error(`aborting artifact upload`); + core19.error(`aborting artifact upload`); abortPendingFileUploads = true; } } @@ -157565,7 +157949,7 @@ var require_upload_http_client = __commonJS({ }))); this.statusReporter.stop(); this.uploadHttpManager.disposeAndReplaceAllClients(); - core18.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`); + core19.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`); return { uploadSize: uploadFileSize, totalSize: totalFileSize, @@ -157591,16 +157975,16 @@ var require_upload_http_client = __commonJS({ let uploadFileSize = 0; let isGzip = true; if (!isFIFO && totalFileSize < 65536) { - core18.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`); + core19.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`); const buffer = yield (0, upload_gzip_1.createGZipFileInBuffer)(parameters.file); let openUploadStream; if (totalFileSize < buffer.byteLength) { - core18.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); + core19.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); openUploadStream = () => fs20.createReadStream(parameters.file); isGzip = false; uploadFileSize = totalFileSize; } else { - core18.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`); + core19.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`); openUploadStream = () => { const passThrough = new stream2.PassThrough(); passThrough.end(buffer); @@ -157612,7 +157996,7 @@ var require_upload_http_client = __commonJS({ if (!result) { isUploadSuccessful = false; failedChunkSizes += uploadFileSize; - core18.warning(`Aborting upload for ${parameters.file} due to failure`); + core19.warning(`Aborting upload for ${parameters.file} due to failure`); } return { isSuccess: isUploadSuccessful, @@ -157621,16 +158005,16 @@ var require_upload_http_client = __commonJS({ }; } else { const tempFile = yield tmp.file(); - core18.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`); + core19.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`); uploadFileSize = yield (0, upload_gzip_1.createGZipFileOnDisk)(parameters.file, tempFile.path); let uploadFilePath = tempFile.path; if (!isFIFO && totalFileSize < uploadFileSize) { - core18.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); + core19.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); uploadFileSize = totalFileSize; uploadFilePath = parameters.file; isGzip = false; } else { - core18.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`); + core19.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`); } let abortFileUpload = false; while (offset < uploadFileSize) { @@ -157650,7 +158034,7 @@ var require_upload_http_client = __commonJS({ if (!result) { isUploadSuccessful = false; failedChunkSizes += chunkSize; - core18.warning(`Aborting upload for ${parameters.file} due to failure`); + core19.warning(`Aborting upload for ${parameters.file} due to failure`); abortFileUpload = true; } else { if (uploadFileSize > 8388608) { @@ -157658,7 +158042,7 @@ var require_upload_http_client = __commonJS({ } } } - core18.debug(`deleting temporary gzip file ${tempFile.path}`); + core19.debug(`deleting temporary gzip file ${tempFile.path}`); yield tempFile.cleanup(); return { isSuccess: isUploadSuccessful, @@ -157697,7 +158081,7 @@ var require_upload_http_client = __commonJS({ if (response) { (0, utils_1.displayHttpDiagnostics)(response); } - core18.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`); + core19.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`); return true; } return false; @@ -157705,14 +158089,14 @@ var require_upload_http_client = __commonJS({ const backOff = (retryAfterValue) => __awaiter2(this, void 0, void 0, function* () { this.uploadHttpManager.disposeAndReplaceClient(httpClientIndex); if (retryAfterValue) { - core18.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`); + core19.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`); yield (0, utils_1.sleep)(retryAfterValue); } else { const backoffTime = (0, utils_1.getExponentialRetryTimeInMilliseconds)(retryCount); - core18.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`); + core19.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`); yield (0, utils_1.sleep)(backoffTime); } - core18.info(`Finished backoff for retry #${retryCount}, continuing with upload`); + core19.info(`Finished backoff for retry #${retryCount}, continuing with upload`); return; }); while (retryCount <= retryLimit) { @@ -157720,7 +158104,7 @@ var require_upload_http_client = __commonJS({ try { response = yield uploadChunkRequest(); } catch (error3) { - core18.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`); + core19.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`); console.log(error3); if (incrementAndCheckRetryLimit()) { return false; @@ -157732,13 +158116,13 @@ var require_upload_http_client = __commonJS({ if ((0, utils_1.isSuccessStatusCode)(response.message.statusCode)) { return true; } else if ((0, utils_1.isRetryableStatusCode)(response.message.statusCode)) { - core18.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`); + core19.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`); if (incrementAndCheckRetryLimit(response)) { return false; } (0, utils_1.isThrottledStatusCode)(response.message.statusCode) ? yield backOff((0, utils_1.tryGetRetryAfterValueTimeInMilliseconds)(response.message.headers)) : yield backOff(); } else { - core18.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`); + core19.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`); (0, utils_1.displayHttpDiagnostics)(response); return false; } @@ -157756,7 +158140,7 @@ var require_upload_http_client = __commonJS({ resourceUrl.searchParams.append("artifactName", artifactName); const parameters = { Size: size }; const data = JSON.stringify(parameters, null, 2); - core18.debug(`URL is ${resourceUrl.toString()}`); + core19.debug(`URL is ${resourceUrl.toString()}`); const client = this.uploadHttpManager.getClient(0); const headers = (0, utils_1.getUploadHeaders)("application/json", false); const customErrorMessages = /* @__PURE__ */ new Map([ @@ -157769,7 +158153,7 @@ var require_upload_http_client = __commonJS({ return client.patch(resourceUrl.toString(), data, headers); }), customErrorMessages); yield response.readBody(); - core18.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`); + core19.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`); }); } }; @@ -157838,7 +158222,7 @@ var require_download_http_client = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DownloadHttpClient = void 0; var fs20 = __importStar2(require("fs")); - var core18 = __importStar2(require_core3()); + var core19 = __importStar2(require_core3()); var zlib3 = __importStar2(require("zlib")); var utils_1 = require_utils13(); var url_1 = require("url"); @@ -157892,11 +158276,11 @@ var require_download_http_client = __commonJS({ downloadSingleArtifact(downloadItems) { return __awaiter2(this, void 0, void 0, function* () { const DOWNLOAD_CONCURRENCY = (0, config_variables_1.getDownloadFileConcurrency)(); - core18.debug(`Download file concurrency is set to ${DOWNLOAD_CONCURRENCY}`); + core19.debug(`Download file concurrency is set to ${DOWNLOAD_CONCURRENCY}`); const parallelDownloads = [...new Array(DOWNLOAD_CONCURRENCY).keys()]; let currentFile = 0; let downloadedFiles = 0; - core18.info(`Total number of files that will be downloaded: ${downloadItems.length}`); + core19.info(`Total number of files that will be downloaded: ${downloadItems.length}`); this.statusReporter.setTotalNumberOfFilesToProcess(downloadItems.length); this.statusReporter.start(); yield Promise.all(parallelDownloads.map((index) => __awaiter2(this, void 0, void 0, function* () { @@ -157905,8 +158289,8 @@ var require_download_http_client = __commonJS({ currentFile += 1; const startTime = perf_hooks_1.performance.now(); yield this.downloadIndividualFile(index, currentFileToDownload.sourceLocation, currentFileToDownload.targetPath); - if (core18.isDebug()) { - core18.debug(`File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish downloading`); + if (core19.isDebug()) { + core19.debug(`File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish downloading`); } this.statusReporter.incrementProcessedCount(); } @@ -157944,19 +158328,19 @@ var require_download_http_client = __commonJS({ } else { this.downloadHttpManager.disposeAndReplaceClient(httpClientIndex); if (retryAfterValue) { - core18.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the download`); + core19.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the download`); yield (0, utils_1.sleep)(retryAfterValue); } else { const backoffTime = (0, utils_1.getExponentialRetryTimeInMilliseconds)(retryCount); - core18.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the download`); + core19.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the download`); yield (0, utils_1.sleep)(backoffTime); } - core18.info(`Finished backoff for retry #${retryCount}, continuing with download`); + core19.info(`Finished backoff for retry #${retryCount}, continuing with download`); } }); const isAllBytesReceived = (expected, received) => { if (!expected || !received || process.env["ACTIONS_ARTIFACT_SKIP_DOWNLOAD_VALIDATION"]) { - core18.info("Skipping download validation."); + core19.info("Skipping download validation."); return true; } return parseInt(expected) === received; @@ -157977,7 +158361,7 @@ var require_download_http_client = __commonJS({ try { response = yield makeDownloadRequest(); } catch (error3) { - core18.info("An error occurred while attempting to download a file"); + core19.info("An error occurred while attempting to download a file"); console.log(error3); yield backOff(); continue; @@ -157997,7 +158381,7 @@ var require_download_http_client = __commonJS({ } } if (forceRetry || (0, utils_1.isRetryableStatusCode)(response.message.statusCode)) { - core18.info(`A ${response.message.statusCode} response code has been received while attempting to download an artifact`); + core19.info(`A ${response.message.statusCode} response code has been received while attempting to download an artifact`); resetDestinationStream(downloadPath); (0, utils_1.isThrottledStatusCode)(response.message.statusCode) ? yield backOff((0, utils_1.tryGetRetryAfterValueTimeInMilliseconds)(response.message.headers)) : yield backOff(); } else { @@ -158019,29 +158403,29 @@ var require_download_http_client = __commonJS({ if (isGzip) { const gunzip = zlib3.createGunzip(); response.message.on("error", (error3) => { - core18.info(`An error occurred while attempting to read the response stream`); + core19.info(`An error occurred while attempting to read the response stream`); gunzip.close(); destinationStream.close(); reject(error3); }).pipe(gunzip).on("error", (error3) => { - core18.info(`An error occurred while attempting to decompress the response stream`); + core19.info(`An error occurred while attempting to decompress the response stream`); destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { resolve8(); }).on("error", (error3) => { - core18.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); + core19.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); }); } else { response.message.on("error", (error3) => { - core18.info(`An error occurred while attempting to read the response stream`); + core19.info(`An error occurred while attempting to read the response stream`); destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { resolve8(); }).on("error", (error3) => { - core18.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); + core19.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); }); } @@ -158180,7 +158564,7 @@ var require_artifact_client = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultArtifactClient = void 0; - var core18 = __importStar2(require_core3()); + var core19 = __importStar2(require_core3()); var upload_specification_1 = require_upload_specification(); var upload_http_client_1 = require_upload_http_client(); var utils_1 = require_utils13(); @@ -158201,7 +158585,7 @@ var require_artifact_client = __commonJS({ */ uploadArtifact(name, files, rootDirectory, options) { return __awaiter2(this, void 0, void 0, function* () { - core18.info(`Starting artifact upload + core19.info(`Starting artifact upload For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging`); (0, path_and_artifact_name_validation_1.checkArtifactName)(name); const uploadSpecification = (0, upload_specification_1.getUploadSpecification)(name, rootDirectory, files); @@ -158213,24 +158597,24 @@ For more detailed logs during the artifact upload process, enable step-debugging }; const uploadHttpClient = new upload_http_client_1.UploadHttpClient(); if (uploadSpecification.length === 0) { - core18.warning(`No files found that can be uploaded`); + core19.warning(`No files found that can be uploaded`); } else { const response = yield uploadHttpClient.createArtifactInFileContainer(name, options); if (!response.fileContainerResourceUrl) { - core18.debug(response.toString()); + core19.debug(response.toString()); throw new Error("No URL provided by the Artifact Service to upload an artifact to"); } - core18.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); - core18.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`); + core19.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); + core19.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`); const uploadResult = yield uploadHttpClient.uploadArtifactToFileContainer(response.fileContainerResourceUrl, uploadSpecification, options); - core18.info(`File upload process has finished. Finalizing the artifact upload`); + core19.info(`File upload process has finished. Finalizing the artifact upload`); yield uploadHttpClient.patchArtifactSize(uploadResult.totalSize, name); if (uploadResult.failedItems.length > 0) { - core18.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`); + core19.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`); } else { - core18.info(`Artifact has been finalized. All files have been successfully uploaded!`); + core19.info(`Artifact has been finalized. All files have been successfully uploaded!`); } - core18.info(` + core19.info(` The raw size of all the files that were specified for upload is ${uploadResult.totalSize} bytes The size of all the files that were uploaded is ${uploadResult.uploadSize} bytes. This takes into account any gzip compression used to reduce the upload size, time and storage @@ -158264,10 +158648,10 @@ Note: The size of downloaded zips can differ significantly from the reported siz path19 = (0, path_1.resolve)(path19); const downloadSpecification = (0, download_specification_1.getDownloadSpecification)(name, items.value, path19, (options === null || options === void 0 ? void 0 : options.createArtifactFolder) || false); if (downloadSpecification.filesToDownload.length === 0) { - core18.info(`No downloadable files were found for the artifact: ${artifactToDownload.name}`); + core19.info(`No downloadable files were found for the artifact: ${artifactToDownload.name}`); } else { yield (0, utils_1.createDirectoriesForArtifact)(downloadSpecification.directoryStructure); - core18.info("Directory structure has been set up for the artifact"); + core19.info("Directory structure has been set up for the artifact"); yield (0, utils_1.createEmptyFilesForArtifact)(downloadSpecification.emptyFilesToCreate); yield downloadHttpClient.downloadSingleArtifact(downloadSpecification.filesToDownload); } @@ -158283,7 +158667,7 @@ Note: The size of downloaded zips can differ significantly from the reported siz const response = []; const artifacts = yield downloadHttpClient.listArtifacts(); if (artifacts.count === 0) { - core18.info("Unable to find any artifacts for the associated workflow"); + core19.info("Unable to find any artifacts for the associated workflow"); return response; } if (!path19) { @@ -158295,11 +158679,11 @@ Note: The size of downloaded zips can differ significantly from the reported siz while (downloadedArtifacts < artifacts.count) { const currentArtifactToDownload = artifacts.value[downloadedArtifacts]; downloadedArtifacts += 1; - core18.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`); + core19.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`); const items = yield downloadHttpClient.getContainerItems(currentArtifactToDownload.name, currentArtifactToDownload.fileContainerResourceUrl); const downloadSpecification = (0, download_specification_1.getDownloadSpecification)(currentArtifactToDownload.name, items.value, path19, true); if (downloadSpecification.filesToDownload.length === 0) { - core18.info(`No downloadable files were found for any artifact ${currentArtifactToDownload.name}`); + core19.info(`No downloadable files were found for any artifact ${currentArtifactToDownload.name}`); } else { yield (0, utils_1.createDirectoriesForArtifact)(downloadSpecification.directoryStructure); yield (0, utils_1.createEmptyFilesForArtifact)(downloadSpecification.emptyFilesToCreate); @@ -161229,7 +161613,7 @@ var require_sarif_schema_2_1_0 = __commonJS({ }); // src/init-action-post.ts -var core17 = __toESM(require_core()); +var core18 = __toESM(require_core()); // src/actions-util.ts var fs2 = __toESM(require("fs")); @@ -164251,7 +164635,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -164715,7 +165099,7 @@ var core6 = __toESM(require_core()); // src/codeql.ts var fs11 = __toESM(require("fs")); var path11 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -164963,6 +165347,7 @@ function wrapCliConfigurationError(cliError) { // src/config-utils.ts var fs7 = __toESM(require("fs")); var path8 = __toESM(require("path")); +var core9 = __toESM(require_core()); // src/analyses.ts var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => { @@ -165145,8 +165530,8 @@ var path5 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.24.3"; -var cliVersion = "2.24.3"; +var bundleVersion = "codeql-bundle-v2.25.0"; +var cliVersion = "2.25.0"; // src/overlay/index.ts var fs3 = __toESM(require("fs")); @@ -165354,6 +165739,7 @@ async function isAnalyzingDefaultBranch() { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -165508,6 +165894,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -165538,6 +165929,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -165548,16 +165944,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -165573,15 +165959,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -166036,6 +166438,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -166044,6 +166447,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -166324,7 +166728,7 @@ var fs9 = __toESM(require("fs")); var os = __toESM(require("os")); var path9 = __toESM(require("path")); var import_perf_hooks = require("perf_hooks"); -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -166378,10 +166782,10 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat }; } } catch (e) { - core9.warning( + core10.warning( `Failed to download and extract CodeQL bundle using streaming with error: ${getErrorMessage(e)}` ); - core9.warning(`Falling back to downloading the bundle before extracting.`); + core10.warning(`Falling back to downloading the bundle before extracting.`); await cleanUpPath(dest, "CodeQL bundle", logger); } const toolsDownloadStart = import_perf_hooks.performance.now(); @@ -167063,7 +167467,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, checkVersion) { try { const { @@ -167407,17 +167810,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -167566,12 +167965,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core10.warning( + core11.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core10.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -167681,7 +168080,7 @@ var fs14 = __toESM(require("fs")); var path14 = __toESM(require("path")); var artifact = __toESM(require_artifact2()); var artifactLegacy = __toESM(require_artifact_client2()); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); var import_archiver = __toESM(require_archiver()); // src/analyze.ts @@ -167690,7 +168089,7 @@ var path12 = __toESM(require("path")); var io5 = __toESM(require_io()); // src/autobuild.ts -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); // src/dependency-caching.ts var actionsCache4 = __toESM(require_cache5()); @@ -168101,10 +168500,10 @@ function getArtifactSuffix(matrix) { for (const matrixKey of Object.keys(matrixObject).sort()) suffix += `-${matrixObject[matrixKey]}`; } else { - core12.warning("User-specified `matrix` input is not an object."); + core13.warning("User-specified `matrix` input is not an object."); } } catch { - core12.warning( + core13.warning( "Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input." ); } @@ -168114,7 +168513,7 @@ function getArtifactSuffix(matrix) { async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghVariant, codeQlVersion) { const uploadSupported = isSafeArtifactUpload(codeQlVersion); if (!uploadSupported) { - core12.info( + core13.info( `Skipping debug artifact upload because the current CLI does not support safe upload. Please upgrade to CLI v${SafeArtifactUploadVersion} or later.` ); return "upload-not-supported"; @@ -168127,7 +168526,7 @@ async function uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVarian } if (isInTestMode()) { await scanArtifactsForTokens(toUpload, logger); - core12.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true"); + core13.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true"); } const suffix = getArtifactSuffix(getOptionalInput("matrix")); const artifactUploader = await getArtifactUploaderClient(logger, ghVariant); @@ -168143,7 +168542,7 @@ async function uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVarian ); return "upload-successful"; } catch (e) { - core12.warning(`Failed to upload debug artifacts: ${e}`); + core13.warning(`Failed to upload debug artifacts: ${e}`); return "upload-failed"; } } @@ -168166,7 +168565,7 @@ async function createPartialDatabaseBundle(config, language) { config.dbLocation, `${config.debugDatabaseName}-${language}-partial.zip` ); - core12.info( + core13.info( `${config.debugDatabaseName}-${language} is not finalized. Uploading partial database bundle at ${databaseBundlePath}...` ); if (fs14.existsSync(databaseBundlePath)) { @@ -168208,7 +168607,7 @@ var fs17 = __toESM(require("fs")); var path16 = __toESM(require("path")); var url = __toESM(require("url")); var import_zlib = __toESM(require("zlib")); -var core14 = __toESM(require_core()); +var core15 = __toESM(require_core()); var jsonschema2 = __toESM(require_lib2()); // src/fingerprints.ts @@ -169334,7 +169733,7 @@ async function addFingerprints(sarifLog, sourceRoot, logger) { } // src/init.ts -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); var toolrunner4 = __toESM(require_toolrunner()); var github2 = __toESM(require_github()); var io6 = __toESM(require_io()); @@ -169478,7 +169877,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo logger.warning( `Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}` ); - core14.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); + core15.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); } return combineSarifFiles(sarifFiles, logger); } @@ -169577,13 +169976,13 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) { if (httpError !== void 0) { switch (httpError.status) { case 403: - core14.warning(httpError.message || GENERIC_403_MSG); + core15.warning(httpError.message || GENERIC_403_MSG); break; case 404: - core14.warning(httpError.message || GENERIC_404_MSG); + core15.warning(httpError.message || GENERIC_404_MSG); break; default: - core14.warning(httpError.message); + core15.warning(httpError.message); break; } } @@ -169941,7 +170340,7 @@ function validateUniqueCategory(sarifLog, sentinelPrefix) { `Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per tool/category. The easiest fix is to specify a unique value for the \`category\` input. If .runs[].automationDetails.id is specified in the sarif file, that will take precedence over your configured \`category\`. Category: (${id ? id : "none"}) Tool: (${tool ? tool : "none"})` ); } - core14.exportVariable(sentinelEnvVar, sentinelEnvVar); + core15.exportVariable(sentinelEnvVar, sentinelEnvVar); } } function sanitize(str2) { @@ -169955,7 +170354,6 @@ function filterAlertsByDiffRange(logger, sarifLog) { if (sarifLog.runs === void 0) { return sarifLog; } - const checkoutPath = getRequiredInput("checkout_path"); for (const run2 of sarifLog.runs) { if (run2.results) { run2.results = run2.results.filter((result) => { @@ -169969,9 +170367,8 @@ function filterAlertsByDiffRange(logger, sarifLog) { if (!locationUri || locationStartLine === void 0) { return false; } - const locationPath = path16.join(checkoutPath, locationUri).replaceAll(path16.sep, "/"); return diffRanges.some( - (range) => range.path === locationPath && (range.startLine <= locationStartLine && range.endLine >= locationStartLine || range.startLine === 0 && range.endLine === 0) + (range) => range.path === locationUri && (range.startLine <= locationStartLine && range.endLine >= locationStartLine || range.startLine === 0 && range.endLine === 0) ); }); }); @@ -169984,7 +170381,7 @@ function filterAlertsByDiffRange(logger, sarifLog) { var fs18 = __toESM(require("fs")); var path17 = __toESM(require("path")); var import_zlib2 = __toESM(require("zlib")); -var core15 = __toESM(require_core()); +var core16 = __toESM(require_core()); function toCodedErrors(errors) { return Object.entries(errors).reduce( (acc, [code, message]) => { @@ -170418,7 +170815,7 @@ async function removeUploadedSarif(uploadFailedSarifResult, logger) { // src/status-report.ts var os3 = __toESM(require("os")); -var core16 = __toESM(require_core()); +var core17 = __toESM(require_core()); function isFirstPartyAnalysis(actionName) { if (actionName !== "upload-sarif" /* UploadSarif */) { return true; @@ -170455,12 +170852,12 @@ function getJobStatusDisplayName(status) { } function setJobStatusIfUnsuccessful(actionStatus) { if (actionStatus === "user-error") { - core16.exportVariable( + core17.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); } else if (actionStatus === "failure" || actionStatus === "aborted") { - core16.exportVariable( + core17.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_FAILURE" /* FailureStatus */ ); @@ -170479,14 +170876,14 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi let workflowStartedAt = process.env["CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */]; if (workflowStartedAt === void 0) { workflowStartedAt = actionStartedAt.toISOString(); - core16.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); + core17.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); const codeQlCliVersion = getCachedCodeQlVersion(); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { - core16.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); + core17.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); } const isSteadyStateDefaultSetupRun = process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true"; const statusReport = { @@ -170569,9 +170966,9 @@ var INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the API endpo async function sendStatusReport(statusReport) { setJobStatusIfUnsuccessful(statusReport.status); const statusReportJSON = JSON.stringify(statusReport); - core16.debug(`Sending status report: ${statusReportJSON}`); + core17.debug(`Sending status report: ${statusReportJSON}`); if (isInTestMode()) { - core16.debug("In test mode. Status reports are not uploaded."); + core17.debug("In test mode. Status reports are not uploaded."); return; } const nwo = getRepositoryNwo(); @@ -170591,28 +170988,28 @@ async function sendStatusReport(statusReport) { switch (httpError.status) { case 403: if (getWorkflowEventName() === "push" && process.env["GITHUB_ACTOR"] === "dependabot[bot]") { - core16.warning( + core17.warning( `Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading CodeQL results requires write access. To use CodeQL with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. See ${"https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push" /* SCANNING_ON_PUSH */} for more information on how to configure these events.` ); } else { - core16.warning( + core17.warning( `This run of the CodeQL Action does not have permission to access the CodeQL Action API endpoints. This could be because the Action is running on a pull request from a fork. If not, please ensure the workflow has at least the 'security-events: read' permission. Details: ${httpError.message}` ); } return; case 404: - core16.warning(httpError.message); + core17.warning(httpError.message); return; case 422: if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { - core16.debug(INCOMPATIBLE_MSG); + core17.debug(INCOMPATIBLE_MSG); } else { - core16.debug(OUT_OF_DATE_MSG); + core17.debug(OUT_OF_DATE_MSG); } return; } } - core16.warning( + core17.warning( `An unexpected error occurred when sending a status report: ${getErrorMessage( e )}` @@ -170683,7 +171080,7 @@ async function run(startedAt) { } } catch (unwrappedError) { const error3 = wrapError(unwrappedError); - core17.setFailed(error3.message); + core18.setFailed(error3.message); const statusReportBase2 = await createStatusReportBase( "init-post" /* InitPost */, getActionsStatus(error3), @@ -170728,14 +171125,14 @@ function getFinalJobStatus(config) { } let jobStatus; if (process.env["CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */] === "true") { - core17.exportVariable("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, "JOB_STATUS_SUCCESS" /* SuccessStatus */); + core18.exportVariable("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, "JOB_STATUS_SUCCESS" /* SuccessStatus */); jobStatus = "JOB_STATUS_SUCCESS" /* SuccessStatus */; } else if (config !== void 0) { jobStatus = "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */; } else { jobStatus = "JOB_STATUS_UNKNOWN" /* UnknownStatus */; } - core17.exportVariable("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, jobStatus); + core18.exportVariable("CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, jobStatus); return jobStatus; } function getJobStatusFromEnvironment() { @@ -170754,7 +171151,7 @@ async function runWrapper() { try { await run(startedAt); } catch (error3) { - core17.setFailed(`init post action failed: ${wrapError(error3).message}`); + core18.setFailed(`init post action failed: ${wrapError(error3).message}`); await sendUnhandledErrorStatusReport( "init-post" /* InitPost */, startedAt, diff --git a/lib/init-action.js b/lib/init-action.js index 1b3244b10e..4fbe0fd7d0 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable7; + exports2.exportVariable = exportVariable8; exports2.setSecret = setSecret; exports2.addPath = addPath2; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable7(name, val) { + function exportVariable8(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -48791,7 +48791,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -48803,23 +48803,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core15.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core16.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core15.debug(`implicitDescendants '${result.implicitDescendants}'`); + core16.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core15.debug(`matchDirectories '${result.matchDirectories}'`); + core16.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core15.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core16.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core15.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core16.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -50447,7 +50447,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var fs16 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path17 = __importStar2(require("path")); @@ -50500,7 +50500,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core15.debug(`Search path '${searchPath}'`); + core16.debug(`Search path '${searchPath}'`); try { yield __await2(fs16.promises.lstat(searchPath)); } catch (err) { @@ -50575,7 +50575,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core15.debug(`Broken symlink '${item.path}'`); + core16.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -50591,7 +50591,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core15.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core16.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -50694,7 +50694,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles2; var crypto3 = __importStar2(require("crypto")); - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var fs16 = __importStar2(require("fs")); var stream2 = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -50703,7 +50703,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core15.info : core15.debug; + const writeDelegate = verbose ? core16.info : core16.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto3.createHash("sha256"); @@ -52094,7 +52094,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var exec = __importStar2(require_exec()); var glob2 = __importStar2(require_glob()); var io7 = __importStar2(require_io()); @@ -52145,7 +52145,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path17.relative(workspace, file).replace(new RegExp(`\\${path17.sep}`, "g"), "/"); - core15.debug(`Matched: ${relativeFile}`); + core16.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -52173,7 +52173,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core15.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core16.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -52184,10 +52184,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core15.debug(err.message); + core16.debug(err.message); } versionOutput = versionOutput.trim(); - core15.debug(versionOutput); + core16.debug(versionOutput); return versionOutput; }); } @@ -52195,7 +52195,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver10.clean(versionOutput); - core15.debug(`zstd version: ${version}`); + core16.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -61978,44 +61978,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -62023,63 +62023,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -62088,16 +62088,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -62106,83 +62106,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62196,190 +62203,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -62389,290 +62605,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; + } + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; + } + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function lt2(t2, e2, i2) { + return pt(t2, e2, i2); } - function H(t2, e2, n2) { - let i2; + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt2(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62681,172 +62932,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt2(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } + } + return i2; + } + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return s2; + return i2; } - function ot(t2) { + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt2(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -91851,7 +92235,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -91893,7 +92277,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core15.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core16.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91950,14 +92334,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core15.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core16.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core15.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core16.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -92042,7 +92426,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -92100,9 +92484,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core15.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core16.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core15.debug(`${name} - Error is not retryable`); + core16.debug(`${name} - Error is not retryable`); break; } yield sleep(delay2); @@ -92361,7 +92745,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -92399,7 +92783,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core15.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core16.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -92433,7 +92817,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core15.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core16.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -92483,7 +92867,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core15.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core16.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -92494,7 +92878,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core15.debug("Unable to validate download, no Content-Length header"); + core16.debug("Unable to validate download, no Content-Length header"); } }); } @@ -92612,7 +92996,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core15.debug("Unable to determine content length, downloading file with http-client..."); + core16.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -92702,7 +93086,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -92722,9 +93106,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core15.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core15.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core16.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core16.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core16.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -92760,12 +93144,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core15.debug(`Download concurrency: ${result.downloadConcurrency}`); - core15.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core15.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core15.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core15.debug(`Lookup only: ${result.lookupOnly}`); + core16.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core16.debug(`Download concurrency: ${result.downloadConcurrency}`); + core16.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core16.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core16.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core16.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -92959,7 +93343,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache5; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs16 = __importStar2(require("fs")); @@ -92977,7 +93361,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url = `${baseUrl}_apis/artifactcache/${resource}`; - core15.debug(`Resource Url: ${url}`); + core16.debug(`Resource Url: ${url}`); return url; } function createAcceptHeader(type2, apiVersion) { @@ -93005,7 +93389,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core15.isDebug()) { + if (core16.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -93018,9 +93402,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core15.setSecret(cacheDownloadUrl); - core15.debug(`Cache Result:`); - core15.debug(JSON.stringify(cacheResult)); + core16.setSecret(cacheDownloadUrl); + core16.debug(`Cache Result:`); + core16.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -93034,10 +93418,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core15.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core16.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core15.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core16.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -93080,7 +93464,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core15.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core16.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -93102,7 +93486,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core15.debug("Awaiting all uploads"); + core16.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -93145,16 +93529,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core15.debug("Upload cache"); + core16.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core15.debug("Commiting cache"); + core16.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core16.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core15.info("Cache saved successfully"); + core16.info("Cache saved successfully"); } }); } @@ -98637,7 +99021,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache5; exports2.saveCache = saveCache5; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var path17 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -98696,7 +99080,7 @@ var require_cache5 = __commonJS({ function restoreCache5(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core15.debug(`Cache service version: ${cacheServiceVersion}`); + core16.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -98711,8 +99095,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core15.debug("Resolved Keys:"); - core15.debug(JSON.stringify(keys)); + core16.debug("Resolved Keys:"); + core16.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98730,19 +99114,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core15.info("Lookup only - skipping download"); + core16.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path17.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core15.debug(`Archive Path: ${archivePath}`); + core16.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core15.isDebug()) { + if (core16.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core16.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core15.info("Cache restored successfully"); + core16.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -98750,16 +99134,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core15.error(`Failed to restore: ${error3.message}`); + core16.error(`Failed to restore: ${error3.message}`); } else { - core15.warning(`Failed to restore: ${error3.message}`); + core16.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core15.debug(`Failed to delete archive: ${error3}`); + core16.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98770,8 +99154,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core15.debug("Resolved Keys:"); - core15.debug(JSON.stringify(keys)); + core16.debug("Resolved Keys:"); + core16.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98789,30 +99173,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core15.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core16.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core15.info(`Cache hit for restore-key: ${response.matchedKey}`); + core16.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core15.info(`Cache hit for: ${response.matchedKey}`); + core16.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core15.info("Lookup only - skipping download"); + core16.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path17.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core15.debug(`Archive path: ${archivePath}`); - core15.debug(`Starting download of archive to: ${archivePath}`); + core16.debug(`Archive path: ${archivePath}`); + core16.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core15.isDebug()) { + core16.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core16.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core15.info("Cache restored successfully"); + core16.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -98820,9 +99204,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core15.error(`Failed to restore: ${error3.message}`); + core16.error(`Failed to restore: ${error3.message}`); } else { - core15.warning(`Failed to restore: ${error3.message}`); + core16.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -98831,7 +99215,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core15.debug(`Failed to delete archive: ${error3}`); + core16.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98840,7 +99224,7 @@ var require_cache5 = __commonJS({ function saveCache5(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core15.debug(`Cache service version: ${cacheServiceVersion}`); + core16.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -98858,26 +99242,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core15.debug("Cache Paths:"); - core15.debug(`${JSON.stringify(cachePaths)}`); + core16.debug("Cache Paths:"); + core16.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path17.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core15.debug(`Archive Path: ${archivePath}`); + core16.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core15.isDebug()) { + if (core16.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.debug(`File Size: ${archiveFileSize}`); + core16.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core15.debug("Reserving Cache"); + core16.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -98890,26 +99274,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core15.debug(`Saving Cache (ID: ${cacheId})`); + core16.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core15.info(`Failed to save: ${typedError.message}`); + core16.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core15.error(`Failed to save: ${typedError.message}`); + core16.error(`Failed to save: ${typedError.message}`); } else { - core15.warning(`Failed to save: ${typedError.message}`); + core16.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core15.debug(`Failed to delete archive: ${error3}`); + core16.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -98922,23 +99306,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core15.debug("Cache Paths:"); - core15.debug(`${JSON.stringify(cachePaths)}`); + core16.debug("Cache Paths:"); + core16.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path17.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core15.debug(`Archive Path: ${archivePath}`); + core16.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core15.isDebug()) { + if (core16.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.debug(`File Size: ${archiveFileSize}`); + core16.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core15.debug("Reserving Cache"); + core16.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -98949,16 +99333,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core15.warning(`Cache reservation failed: ${response.message}`); + core16.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core15.debug(`Failed to reserve cache: ${error3}`); + core16.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core15.debug(`Attempting to upload cache located at: ${archivePath}`); + core16.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -98966,7 +99350,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core15.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core16.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -98979,21 +99363,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core15.info(`Failed to save: ${typedError.message}`); + core16.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core15.warning(typedError.message); + core16.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core15.error(`Failed to save: ${typedError.message}`); + core16.error(`Failed to save: ${typedError.message}`); } else { - core15.warning(`Failed to save: ${typedError.message}`); + core16.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core15.debug(`Failed to delete archive: ${error3}`); + core16.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99220,7 +99604,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99243,10 +99627,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core15.info(err.message); + core16.info(err.message); } const seconds = this.getSleepAmount(); - core15.info(`Waiting ${seconds} seconds before trying again`); + core16.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var io7 = __importStar2(require_io()); var crypto3 = __importStar2(require("crypto")); var fs16 = __importStar2(require("fs")); @@ -99378,8 +99762,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path17.join(_getTempDirectory(), crypto3.randomUUID()); yield io7.mkdirP(path17.dirname(dest)); - core15.debug(`Downloading ${url}`); - core15.debug(`Destination ${dest}`); + core16.debug(`Downloading ${url}`); + core16.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99405,7 +99789,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core15.debug("set auth"); + core16.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99414,7 +99798,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core15.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core16.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream2.pipeline); @@ -99423,16 +99807,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs16.createWriteStream(dest)); - core15.debug("download complete"); + core16.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core15.debug("download failed"); + core16.debug("download failed"); try { yield io7.rmRF(dest); } catch (err) { - core15.debug(`Failed to delete '${dest}'. ${err.message}`); + core16.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99447,7 +99831,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core15.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core16.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99500,7 +99884,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core15.debug("Checking tar --version"); + core16.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99510,7 +99894,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core15.debug(versionOutput.trim()); + core16.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99518,7 +99902,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core15.isDebug() && !flags.includes("v")) { + if (core16.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99549,7 +99933,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core15.isDebug()) { + if (core16.isDebug()) { args.push("-v"); } const xarPath = yield io7.which("xar", true); @@ -99592,7 +99976,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core15.debug(`Using pwsh at path: ${pwshPath}`); + core16.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99612,7 +99996,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io7.which("powershell", true); - core15.debug(`Using powershell at path: ${powershellPath}`); + core16.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99621,7 +100005,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io7.which("unzip", true); const args = [file]; - if (!core15.isDebug()) { + if (!core16.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99632,8 +100016,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver10.clean(version) || version; arch2 = arch2 || os6.arch(); - core15.debug(`Caching tool ${tool} ${version} ${arch2}`); - core15.debug(`source dir: ${sourceDir}`); + core16.debug(`Caching tool ${tool} ${version} ${arch2}`); + core16.debug(`source dir: ${sourceDir}`); if (!fs16.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99650,14 +100034,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver10.clean(version) || version; arch2 = arch2 || os6.arch(); - core15.debug(`Caching tool ${tool} ${version} ${arch2}`); - core15.debug(`source file: ${sourceFile}`); + core16.debug(`Caching tool ${tool} ${version} ${arch2}`); + core16.debug(`source file: ${sourceFile}`); if (!fs16.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch2); const destPath = path17.join(destFolder, targetFile); - core15.debug(`destination file ${destPath}`); + core16.debug(`destination file ${destPath}`); yield io7.cp(sourceFile, destPath); _completeToolPath(tool, version, arch2); return destFolder; @@ -99680,12 +100064,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver10.clean(versionSpec) || ""; const cachePath = path17.join(_getCacheDirectory(), toolName, versionSpec, arch2); - core15.debug(`checking cache: ${cachePath}`); + core16.debug(`checking cache: ${cachePath}`); if (fs16.existsSync(cachePath) && fs16.existsSync(`${cachePath}.complete`)) { - core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); + core16.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); toolPath = cachePath; } else { - core15.debug("not found"); + core16.debug("not found"); } } return toolPath; @@ -99714,7 +100098,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core15.debug("set auth"); + core16.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99735,7 +100119,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core15.debug("Invalid json"); + core16.debug("Invalid json"); } } return releases; @@ -99759,7 +100143,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch2) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path17.join(_getCacheDirectory(), tool, semver10.clean(version) || version, arch2 || ""); - core15.debug(`destination ${folderPath}`); + core16.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io7.rmRF(folderPath); yield io7.rmRF(markerPath); @@ -99771,18 +100155,18 @@ var require_tool_cache = __commonJS({ const folderPath = path17.join(_getCacheDirectory(), tool, semver10.clean(version) || version, arch2 || ""); const markerPath = `${folderPath}.complete`; fs16.writeFileSync(markerPath, ""); - core15.debug("finished caching tool"); + core16.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver10.clean(versionSpec) || ""; - core15.debug(`isExplicit: ${c}`); + core16.debug(`isExplicit: ${c}`); const valid3 = semver10.valid(c) != null; - core15.debug(`explicit? ${valid3}`); + core16.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core15.debug(`evaluating ${versions.length} versions`); + core16.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver10.gt(a, b)) { return 1; @@ -99798,9 +100182,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core15.debug(`matched: ${version}`); + core16.debug(`matched: ${version}`); } else { - core15.debug("match not found"); + core16.debug("match not found"); } return version; } @@ -100383,7 +100767,7 @@ __export(init_action_exports, { module.exports = __toCommonJS(init_action_exports); var fs15 = __toESM(require("fs")); var path16 = __toESM(require("path")); -var core14 = __toESM(require_core()); +var core15 = __toESM(require_core()); var github3 = __toESM(require_github()); var io6 = __toESM(require_io()); var semver9 = __toESM(require_semver2()); @@ -103679,7 +104063,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -104241,6 +104625,7 @@ function getDependencyCachingEnabled() { var fs7 = __toESM(require("fs")); var path9 = __toESM(require("path")); var import_perf_hooks = require("perf_hooks"); +var core9 = __toESM(require_core()); // src/config/db-config.ts var path3 = __toESM(require("path")); @@ -104778,8 +105163,8 @@ var path6 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.24.3"; -var cliVersion = "2.24.3"; +var bundleVersion = "codeql-bundle-v2.25.0"; +var cliVersion = "2.25.0"; // src/overlay/index.ts var fs3 = __toESM(require("fs")); @@ -105014,6 +105399,7 @@ async function getGeneratedFiles(workingDirectory) { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -105311,6 +105697,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -105341,6 +105732,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -105351,16 +105747,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -105376,15 +105762,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -106141,7 +106543,6 @@ async function initActionState({ packsInput, buildModeInput, dbLocation, - trapCachingEnabled, dependencyCachingEnabled, debugMode, debugArtifactName, @@ -106185,12 +106586,6 @@ async function initActionState({ input: void 0 }; } - const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime( - trapCachingEnabled, - codeql, - languages, - logger - ); const computedConfig = generateCodeScanningConfig( logger, userConfig, @@ -106210,8 +106605,8 @@ async function initActionState({ debugMode, debugArtifactName, debugDatabaseName, - trapCaches, - trapCacheDownloadTime, + trapCaches: {}, + trapCacheDownloadTime: 0, dependencyCachingEnabled: getCachingKind(dependencyCachingEnabled), dependencyCachingRestoredKeys: [], extraQueryExclusions: [], @@ -106221,14 +106616,10 @@ async function initActionState({ enableFileCoverageInformation }; } -async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logger) { - let trapCaches = {}; - let trapCacheDownloadTime = 0; - if (trapCachingEnabled) { - const start = import_perf_hooks.performance.now(); - trapCaches = await downloadTrapCaches(codeQL, languages, logger); - trapCacheDownloadTime = import_perf_hooks.performance.now() - start; - } +async function downloadCacheWithTime(codeQL, languages, logger) { + const start = import_perf_hooks.performance.now(); + const trapCaches = await downloadTrapCaches(codeQL, languages, logger); + const trapCacheDownloadTime = import_perf_hooks.performance.now() - start; return { trapCaches, trapCacheDownloadTime }; } async function loadUserConfig(logger, configFile, workspacePath, apiDetails, tempDir, validateConfig) { @@ -106252,6 +106643,7 @@ async function loadUserConfig(logger, configFile, workspacePath, apiDetails, tem } } var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -106260,6 +106652,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -106473,6 +106866,31 @@ async function validateOverlayDatabaseMode(overlayDatabaseMode, useOverlayDataba useOverlayDatabaseCaching }); } +async function isTrapCachingEnabled(features, overlayDatabaseMode) { + const trapCaching = getOptionalInput("trap-caching"); + if (trapCaching !== void 0) return trapCaching === "true"; + if (!isHostedRunner()) return false; + if (overlayDatabaseMode !== "none" /* None */ && await features.getValue("overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */)) { + return false; + } + return true; +} +async function setCppTrapCachingEnvironmentVariables(config, logger) { + if (config.languages.includes("cpp" /* cpp */)) { + const envVar = "CODEQL_EXTRACTOR_CPP_TRAP_CACHING"; + if (process.env[envVar]) { + logger.info( + `Environment variable ${envVar} already set, leaving it unchanged.` + ); + } else if (config.trapCaches["cpp" /* cpp */]) { + logger.info("Enabling TRAP caching for C/C++."); + core9.exportVariable(envVar, "true"); + } else { + logger.debug(`Disabling TRAP caching for C/C++.`); + core9.exportVariable(envVar, "false"); + } + } +} function dbLocationOrDefault(dbLocation, tempDir) { return dbLocation || path9.resolve(tempDir, "codeql_databases"); } @@ -106600,6 +107018,16 @@ async function initConfig(features, inputs) { exclude: { tags: "exclude-from-incremental" } }); } + if (await isTrapCachingEnabled(features, config.overlayDatabaseMode)) { + const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime( + inputs.codeql, + config.languages, + logger + ); + config.trapCaches = trapCaches; + config.trapCacheDownloadTime = trapCacheDownloadTime; + } + await setCppTrapCachingEnvironmentVariables(config, logger); return config; } function parseRegistries(registriesInput) { @@ -107010,7 +107438,7 @@ var internal = { // src/init.ts var fs13 = __toESM(require("fs")); var path14 = __toESM(require("path")); -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); var toolrunner4 = __toESM(require_toolrunner()); var github2 = __toESM(require_github()); var io5 = __toESM(require_io()); @@ -107018,7 +107446,7 @@ var io5 = __toESM(require_io()); // src/codeql.ts var fs12 = __toESM(require("fs")); var path13 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -107433,7 +107861,7 @@ var fs9 = __toESM(require("fs")); var os4 = __toESM(require("os")); var path10 = __toESM(require("path")); var import_perf_hooks2 = require("perf_hooks"); -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -107487,10 +107915,10 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat }; } } catch (e) { - core9.warning( + core10.warning( `Failed to download and extract CodeQL bundle using streaming with error: ${getErrorMessage(e)}` ); - core9.warning(`Falling back to downloading the bundle before extracting.`); + core10.warning(`Falling back to downloading the bundle before extracting.`); await cleanUpPath(dest, "CodeQL bundle", logger); } const toolsDownloadStart = import_perf_hooks2.performance.now(); @@ -108194,7 +108622,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, checkVersion) { try { const { @@ -108532,17 +108959,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -108691,12 +109114,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core10.warning( + core11.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core10.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -109026,12 +109449,12 @@ To opt out of this change, switch to an advanced setup workflow and ${envVarOptO To opt out of this change, ${envVarOptOut}`; } logger.warning(message); - core11.exportVariable("CODEQL_ACTION_DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION" /* DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION */, "true"); + core12.exportVariable("CODEQL_ACTION_DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION" /* DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION */, "true"); } // src/status-report.ts var os5 = __toESM(require("os")); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); function isFirstPartyAnalysis(actionName) { if (actionName !== "upload-sarif" /* UploadSarif */) { return true; @@ -109047,12 +109470,12 @@ function getActionsStatus(error3, otherFailureCause) { } function setJobStatusIfUnsuccessful(actionStatus) { if (actionStatus === "user-error") { - core12.exportVariable( + core13.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); } else if (actionStatus === "failure" || actionStatus === "aborted") { - core12.exportVariable( + core13.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_FAILURE" /* FailureStatus */ ); @@ -109071,14 +109494,14 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi let workflowStartedAt = process.env["CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */]; if (workflowStartedAt === void 0) { workflowStartedAt = actionStartedAt.toISOString(); - core12.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); + core13.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); const codeQlCliVersion = getCachedCodeQlVersion(); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { - core12.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); + core13.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); } const isSteadyStateDefaultSetupRun = process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true"; const statusReport = { @@ -109161,9 +109584,9 @@ var INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the API endpo async function sendStatusReport(statusReport) { setJobStatusIfUnsuccessful(statusReport.status); const statusReportJSON = JSON.stringify(statusReport); - core12.debug(`Sending status report: ${statusReportJSON}`); + core13.debug(`Sending status report: ${statusReportJSON}`); if (isInTestMode()) { - core12.debug("In test mode. Status reports are not uploaded."); + core13.debug("In test mode. Status reports are not uploaded."); return; } const nwo = getRepositoryNwo(); @@ -109183,28 +109606,28 @@ async function sendStatusReport(statusReport) { switch (httpError.status) { case 403: if (getWorkflowEventName() === "push" && process.env["GITHUB_ACTOR"] === "dependabot[bot]") { - core12.warning( + core13.warning( `Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading CodeQL results requires write access. To use CodeQL with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. See ${"https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push" /* SCANNING_ON_PUSH */} for more information on how to configure these events.` ); } else { - core12.warning( + core13.warning( `This run of the CodeQL Action does not have permission to access the CodeQL Action API endpoints. This could be because the Action is running on a pull request from a fork. If not, please ensure the workflow has at least the 'security-events: read' permission. Details: ${httpError.message}` ); } return; case 404: - core12.warning(httpError.message); + core13.warning(httpError.message); return; case 422: if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { - core12.debug(INCOMPATIBLE_MSG); + core13.debug(INCOMPATIBLE_MSG); } else { - core12.debug(OUT_OF_DATE_MSG); + core13.debug(OUT_OF_DATE_MSG); } return; } } - core12.warning( + core13.warning( `An unexpected error occurred when sending a status report: ${getErrorMessage( e )}` @@ -109286,7 +109709,7 @@ async function sendUnhandledErrorStatusReport(actionName, actionStartedAt, error var fs14 = __toESM(require("fs")); var path15 = __toESM(require("path")); var import_zlib = __toESM(require("zlib")); -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); function toCodedErrors(errors) { return Object.entries(errors).reduce( (acc, [code, message]) => { @@ -109409,7 +109832,7 @@ async function validateWorkflow(codeql, logger) { } catch (e) { return `error: formatWorkflowErrors() failed: ${String(e)}`; } - core13.warning(message); + core14.warning(message); } return formatWorkflowCause(workflowErrors); } @@ -109455,7 +109878,7 @@ async function getWorkflowAbsolutePath(logger) { } async function checkWorkflow(logger, codeql) { if (!isDynamicWorkflow() && process.env["CODEQL_ACTION_SKIP_WORKFLOW_VALIDATION" /* SKIP_WORKFLOW_VALIDATION */] !== "true") { - core13.startGroup("Validating workflow"); + core14.startGroup("Validating workflow"); const validateWorkflowResult = await internal2.validateWorkflow( codeql, logger @@ -109467,7 +109890,7 @@ async function checkWorkflow(logger, codeql) { `Unable to validate code scanning workflow: ${validateWorkflowResult}` ); } - core13.endGroup(); + core14.endGroup(); } } var internal2 = { @@ -109575,8 +109998,8 @@ async function run(startedAt) { ); const jobRunUuid = v4_default(); logger.info(`Job run UUID is ${jobRunUuid}.`); - core14.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid); - core14.exportVariable("CODEQL_ACTION_INIT_HAS_RUN" /* INIT_ACTION_HAS_RUN */, "true"); + core15.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid); + core15.exportVariable("CODEQL_ACTION_INIT_HAS_RUN" /* INIT_ACTION_HAS_RUN */, "true"); configFile = getOptionalInput("config-file"); sourceRoot = path16.resolve( getRequiredEnvParam("GITHUB_WORKSPACE"), @@ -109629,12 +110052,12 @@ async function run(startedAt) { ); } if (semver9.lt(actualVer, publicPreview)) { - core14.exportVariable("CODEQL_ENABLE_EXPERIMENTAL_FEATURES" /* EXPERIMENTAL_FEATURES */, "true"); + core15.exportVariable("CODEQL_ENABLE_EXPERIMENTAL_FEATURES" /* EXPERIMENTAL_FEATURES */, "true"); logger.info("Experimental Rust analysis enabled"); } } analysisKinds = await getAnalysisKinds(logger); - const debugMode = getOptionalInput("debug") === "true" || core14.isDebug(); + const debugMode = getOptionalInput("debug") === "true" || core15.isDebug(); const repositoryProperties = repositoryPropertiesResult.orElse({}); const fileCoverageResult = await getFileCoverageInformationEnabled( debugMode, @@ -109652,7 +110075,6 @@ async function run(startedAt) { configFile, dbLocation: getOptionalInput("db-location"), configInput: getOptionalInput("config"), - trapCachingEnabled: getTrapCachingEnabled(), dependencyCachingEnabled: getDependencyCachingEnabled(), // Debug mode is enabled if: // - The `init` Action is passed `debug: true`. @@ -109701,7 +110123,7 @@ async function run(startedAt) { await checkInstallPython311(config.languages, codeql); } catch (unwrappedError) { const error3 = wrapError(unwrappedError); - core14.setFailed(error3.message); + core15.setFailed(error3.message); const statusReportBase = await createStatusReportBase( "init" /* Init */, error3 instanceof ConfigurationError ? "user-error" : "aborted", @@ -109751,8 +110173,8 @@ async function run(startedAt) { } const goFlags = process.env["GOFLAGS"]; if (goFlags) { - core14.exportVariable("GOFLAGS", goFlags); - core14.warning( + core15.exportVariable("GOFLAGS", goFlags); + core15.warning( "Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action." ); } @@ -109776,7 +110198,7 @@ async function run(startedAt) { "bin" ); fs15.mkdirSync(tempBinPath, { recursive: true }); - core14.addPath(tempBinPath); + core15.addPath(tempBinPath); const goWrapperPath = path16.resolve(tempBinPath, "go"); fs15.writeFileSync( goWrapperPath, @@ -109785,14 +110207,14 @@ async function run(startedAt) { exec ${goBinaryPath} "$@"` ); fs15.chmodSync(goWrapperPath, "755"); - core14.exportVariable("CODEQL_ACTION_GO_BINARY" /* GO_BINARY_LOCATION */, goWrapperPath); + core15.exportVariable("CODEQL_ACTION_GO_BINARY" /* GO_BINARY_LOCATION */, goWrapperPath); } catch (e) { logger.warning( `Analyzing Go on Linux, but failed to install wrapper script. Tracing custom builds may fail: ${e}` ); } } else { - core14.exportVariable("CODEQL_ACTION_GO_BINARY" /* GO_BINARY_LOCATION */, goBinaryPath); + core15.exportVariable("CODEQL_ACTION_GO_BINARY" /* GO_BINARY_LOCATION */, goBinaryPath); } } catch (e) { logger.warning( @@ -109819,34 +110241,20 @@ exec ${goBinaryPath} "$@"` } } } - core14.exportVariable( + core15.exportVariable( "CODEQL_RAM", process.env["CODEQL_RAM"] || getCodeQLMemoryLimit(getOptionalInput("ram"), logger).toString() ); - core14.exportVariable( + core15.exportVariable( "CODEQL_THREADS", process.env["CODEQL_THREADS"] || getThreadsFlagValue(getOptionalInput("threads"), logger).toString() ); if (await features.getValue("disable_kotlin_analysis_enabled" /* DisableKotlinAnalysisEnabled */)) { - core14.exportVariable("CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN", "true"); + core15.exportVariable("CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN", "true"); } const kotlinLimitVar = "CODEQL_EXTRACTOR_KOTLIN_OVERRIDE_MAXIMUM_VERSION_LIMIT"; if (await codeQlVersionAtLeast(codeql, "2.20.3") && !await codeQlVersionAtLeast(codeql, "2.20.4")) { - core14.exportVariable(kotlinLimitVar, "2.1.20"); - } - if (config.languages.includes("cpp" /* cpp */)) { - const envVar = "CODEQL_EXTRACTOR_CPP_TRAP_CACHING"; - if (process.env[envVar]) { - logger.info( - `Environment variable ${envVar} already set. Not en/disabling CodeQL C++ TRAP caching support` - ); - } else if (getTrapCachingEnabled() && await codeQlVersionAtLeast(codeql, "2.17.5")) { - logger.info("Enabling CodeQL C++ TRAP caching support"); - core14.exportVariable(envVar, "true"); - } else { - logger.info("Disabling CodeQL C++ TRAP caching support"); - core14.exportVariable(envVar, "false"); - } + core15.exportVariable(kotlinLimitVar, "2.1.20"); } if (shouldRestoreCache(config.dependencyCachingEnabled)) { const dependencyCachingResult = await downloadDependencyCaches( @@ -109858,13 +110266,6 @@ exec ${goBinaryPath} "$@"` dependencyCachingStatus = dependencyCachingResult.statusReport; config.dependencyCachingRestoredKeys = dependencyCachingResult.restoredKeys; } - if (await codeQlVersionAtLeast(codeql, "2.17.1")) { - } else { - core14.exportVariable( - "CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION", - "true" - ); - } if (getOptionalInput("setup-python-dependencies") !== void 0) { logger.warning( "The setup-python-dependencies input is deprecated and no longer has any effect. We recommend removing any references from your workflows. See https://github.blog/changelog/2024-01-23-codeql-2-16-python-dependency-installation-disabled-new-queries-and-bug-fixes/ for more information." @@ -109886,7 +110287,7 @@ exec ${goBinaryPath} "$@"` "python_default_is_to_not_extract_stdlib" /* PythonDefaultIsToNotExtractStdlib */, codeql )) { - core14.exportVariable("CODEQL_EXTRACTOR_PYTHON_EXTRACT_STDLIB", "true"); + core15.exportVariable("CODEQL_EXTRACTOR_PYTHON_EXTRACT_STDLIB", "true"); } } if (process.env["CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */]) { @@ -109894,7 +110295,7 @@ exec ${goBinaryPath} "$@"` `${"CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */} is already set to '${process.env["CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */]}', so the Action will not override it.` ); } else if (await codeQlVersionAtLeast(codeql, CODEQL_VERSION_JAR_MINIMIZATION) && config.dependencyCachingEnabled && config.buildMode === "none" /* None */ && config.languages.includes("java" /* java */)) { - core14.exportVariable( + core15.exportVariable( "CODEQL_EXTRACTOR_JAVA_OPTION_MINIMIZE_DEPENDENCY_JARS" /* JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS */, "true" ); @@ -109938,23 +110339,23 @@ exec ${goBinaryPath} "$@"` const tracerConfig = await getCombinedTracerConfig(codeql, config); if (tracerConfig !== void 0) { for (const [key, value] of Object.entries(tracerConfig.env)) { - core14.exportVariable(key, value); + core15.exportVariable(key, value); } } if (await features.getValue("java_network_debugging" /* JavaNetworkDebugging */)) { const existingJavaToolOptions = getOptionalEnvVar("JAVA_TOOL_OPTIONS" /* JAVA_TOOL_OPTIONS */) || ""; - core14.exportVariable( + core15.exportVariable( "JAVA_TOOL_OPTIONS" /* JAVA_TOOL_OPTIONS */, `${existingJavaToolOptions} -Djavax.net.debug=all` ); } flushDiagnostics(config); await saveConfig(config, logger); - core14.setOutput("codeql-path", config.codeQLCmd); - core14.setOutput("codeql-version", (await codeql.getVersion()).version); + core15.setOutput("codeql-path", config.codeQLCmd); + core15.setOutput("codeql-version", (await codeql.getVersion()).version); } catch (unwrappedError) { const error3 = wrapError(unwrappedError); - core14.setFailed(error3.message); + core15.setFailed(error3.message); await sendCompletedStatusReport( startedAt, config, @@ -110006,12 +110407,6 @@ async function loadRepositoryProperties(repositoryNwo, logger) { return new Failure(error3); } } -function getTrapCachingEnabled() { - const trapCaching = getOptionalInput("trap-caching"); - if (trapCaching !== void 0) return trapCaching === "true"; - if (!isHostedRunner()) return false; - return true; -} async function recordZstdAvailability(config, zstdAvailability) { addNoLanguageDiagnostic( config, @@ -110028,7 +110423,7 @@ async function runWrapper() { try { await run(startedAt); } catch (error3) { - core14.setFailed(`init action failed: ${getErrorMessage(error3)}`); + core15.setFailed(`init action failed: ${getErrorMessage(error3)}`); await sendUnhandledErrorStatusReport( "init" /* Init */, startedAt, diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index da48d84049..767c632d4c 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable5; + exports2.exportVariable = exportVariable6; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable5(name, val) { + function exportVariable6(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -48640,7 +48640,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -48652,23 +48652,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core13.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core14.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core13.debug(`implicitDescendants '${result.implicitDescendants}'`); + core14.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core13.debug(`matchDirectories '${result.matchDirectories}'`); + core14.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core13.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core14.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core13.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core14.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -50296,7 +50296,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var fs5 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path5 = __importStar2(require("path")); @@ -50349,7 +50349,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core13.debug(`Search path '${searchPath}'`); + core14.debug(`Search path '${searchPath}'`); try { yield __await2(fs5.promises.lstat(searchPath)); } catch (err) { @@ -50424,7 +50424,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core13.debug(`Broken symlink '${item.path}'`); + core14.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -50440,7 +50440,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core13.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core14.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -50543,7 +50543,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles; var crypto2 = __importStar2(require("crypto")); - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var fs5 = __importStar2(require("fs")); var stream = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -50552,7 +50552,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core13.info : core13.debug; + const writeDelegate = verbose ? core14.info : core14.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -51943,7 +51943,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var exec = __importStar2(require_exec()); var glob = __importStar2(require_glob()); var io5 = __importStar2(require_io()); @@ -51994,7 +51994,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path5.relative(workspace, file).replace(new RegExp(`\\${path5.sep}`, "g"), "/"); - core13.debug(`Matched: ${relativeFile}`); + core14.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -52022,7 +52022,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core13.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core14.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -52033,10 +52033,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core13.debug(err.message); + core14.debug(err.message); } versionOutput = versionOutput.trim(); - core13.debug(versionOutput); + core14.debug(versionOutput); return versionOutput; }); } @@ -52044,7 +52044,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core13.debug(`zstd version: ${version}`); + core14.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -61827,44 +61827,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -61872,63 +61872,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61937,16 +61937,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61955,83 +61955,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62045,190 +62052,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -62238,290 +62454,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; + } + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; + } + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function lt(t2, e2, i2) { + return pt(t2, e2, i2); } - function H(t2, e2, n2) { - let i2; + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62530,172 +62781,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } + } + return i2; + } + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return s2; + return i2; } - function ot(t2) { + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -91700,7 +92084,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -91742,7 +92126,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core13.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core14.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91799,14 +92183,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core13.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core14.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core13.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core14.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -91891,7 +92275,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -91949,9 +92333,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core13.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core14.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core13.debug(`${name} - Error is not retryable`); + core14.debug(`${name} - Error is not retryable`); break; } yield sleep(delay2); @@ -92210,7 +92594,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -92248,7 +92632,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core13.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core14.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -92282,7 +92666,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core13.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core14.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -92332,7 +92716,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core13.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core14.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -92343,7 +92727,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core13.debug("Unable to validate download, no Content-Length header"); + core14.debug("Unable to validate download, no Content-Length header"); } }); } @@ -92461,7 +92845,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core13.debug("Unable to determine content length, downloading file with http-client..."); + core14.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -92551,7 +92935,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -92571,9 +92955,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core13.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core13.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core13.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core14.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core14.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -92609,12 +92993,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core13.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core13.debug(`Download concurrency: ${result.downloadConcurrency}`); - core13.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core13.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core13.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core13.debug(`Lookup only: ${result.lookupOnly}`); + core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core14.debug(`Download concurrency: ${result.downloadConcurrency}`); + core14.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core14.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core14.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core14.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -92808,7 +93192,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache4; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs5 = __importStar2(require("fs")); @@ -92826,7 +93210,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url = `${baseUrl}_apis/artifactcache/${resource}`; - core13.debug(`Resource Url: ${url}`); + core14.debug(`Resource Url: ${url}`); return url; } function createAcceptHeader(type2, apiVersion) { @@ -92854,7 +93238,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core13.isDebug()) { + if (core14.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -92867,9 +93251,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core13.setSecret(cacheDownloadUrl); - core13.debug(`Cache Result:`); - core13.debug(JSON.stringify(cacheResult)); + core14.setSecret(cacheDownloadUrl); + core14.debug(`Cache Result:`); + core14.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -92883,10 +93267,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core13.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core14.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core13.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core14.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -92929,7 +93313,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core13.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core14.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -92951,7 +93335,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core13.debug("Awaiting all uploads"); + core14.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -92994,16 +93378,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core13.debug("Upload cache"); + core14.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core13.debug("Commiting cache"); + core14.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core14.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core13.info("Cache saved successfully"); + core14.info("Cache saved successfully"); } }); } @@ -98486,7 +98870,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache4; exports2.saveCache = saveCache4; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var path5 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -98545,7 +98929,7 @@ var require_cache5 = __commonJS({ function restoreCache4(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core13.debug(`Cache service version: ${cacheServiceVersion}`); + core14.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -98560,8 +98944,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core13.debug("Resolved Keys:"); - core13.debug(JSON.stringify(keys)); + core14.debug("Resolved Keys:"); + core14.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98579,19 +98963,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core13.info("Lookup only - skipping download"); + core14.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path5.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core13.debug(`Archive Path: ${archivePath}`); + core14.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core13.isDebug()) { + if (core14.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core13.info("Cache restored successfully"); + core14.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -98599,16 +98983,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core13.error(`Failed to restore: ${error3.message}`); + core14.error(`Failed to restore: ${error3.message}`); } else { - core13.warning(`Failed to restore: ${error3.message}`); + core14.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core13.debug(`Failed to delete archive: ${error3}`); + core14.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98619,8 +99003,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core13.debug("Resolved Keys:"); - core13.debug(JSON.stringify(keys)); + core14.debug("Resolved Keys:"); + core14.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98638,30 +99022,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core13.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core14.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core13.info(`Cache hit for restore-key: ${response.matchedKey}`); + core14.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core13.info(`Cache hit for: ${response.matchedKey}`); + core14.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core13.info("Lookup only - skipping download"); + core14.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path5.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core13.debug(`Archive path: ${archivePath}`); - core13.debug(`Starting download of archive to: ${archivePath}`); + core14.debug(`Archive path: ${archivePath}`); + core14.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core13.isDebug()) { + core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core14.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core13.info("Cache restored successfully"); + core14.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -98669,9 +99053,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core13.error(`Failed to restore: ${error3.message}`); + core14.error(`Failed to restore: ${error3.message}`); } else { - core13.warning(`Failed to restore: ${error3.message}`); + core14.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -98680,7 +99064,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core13.debug(`Failed to delete archive: ${error3}`); + core14.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98689,7 +99073,7 @@ var require_cache5 = __commonJS({ function saveCache4(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core13.debug(`Cache service version: ${cacheServiceVersion}`); + core14.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -98707,26 +99091,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core13.debug("Cache Paths:"); - core13.debug(`${JSON.stringify(cachePaths)}`); + core14.debug("Cache Paths:"); + core14.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path5.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core13.debug(`Archive Path: ${archivePath}`); + core14.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core13.isDebug()) { + if (core14.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.debug(`File Size: ${archiveFileSize}`); + core14.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core13.debug("Reserving Cache"); + core14.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -98739,26 +99123,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core13.debug(`Saving Cache (ID: ${cacheId})`); + core14.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core13.info(`Failed to save: ${typedError.message}`); + core14.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core13.error(`Failed to save: ${typedError.message}`); + core14.error(`Failed to save: ${typedError.message}`); } else { - core13.warning(`Failed to save: ${typedError.message}`); + core14.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core13.debug(`Failed to delete archive: ${error3}`); + core14.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -98771,23 +99155,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core13.debug("Cache Paths:"); - core13.debug(`${JSON.stringify(cachePaths)}`); + core14.debug("Cache Paths:"); + core14.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path5.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core13.debug(`Archive Path: ${archivePath}`); + core14.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core13.isDebug()) { + if (core14.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.debug(`File Size: ${archiveFileSize}`); + core14.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core13.debug("Reserving Cache"); + core14.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -98798,16 +99182,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core13.warning(`Cache reservation failed: ${response.message}`); + core14.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core13.debug(`Failed to reserve cache: ${error3}`); + core14.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core13.debug(`Attempting to upload cache located at: ${archivePath}`); + core14.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -98815,7 +99199,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core13.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core14.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -98828,21 +99212,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core13.info(`Failed to save: ${typedError.message}`); + core14.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core13.warning(typedError.message); + core14.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core13.error(`Failed to save: ${typedError.message}`); + core14.error(`Failed to save: ${typedError.message}`); } else { - core13.warning(`Failed to save: ${typedError.message}`); + core14.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core13.debug(`Failed to delete archive: ${error3}`); + core14.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99069,7 +99453,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99092,10 +99476,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core13.info(err.message); + core14.info(err.message); } const seconds = this.getSleepAmount(); - core13.info(`Waiting ${seconds} seconds before trying again`); + core14.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99198,7 +99582,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var io5 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs5 = __importStar2(require("fs")); @@ -99227,8 +99611,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path5.join(_getTempDirectory(), crypto2.randomUUID()); yield io5.mkdirP(path5.dirname(dest)); - core13.debug(`Downloading ${url}`); - core13.debug(`Destination ${dest}`); + core14.debug(`Downloading ${url}`); + core14.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99254,7 +99638,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core13.debug("set auth"); + core14.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99263,7 +99647,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core13.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core14.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream.pipeline); @@ -99272,16 +99656,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs5.createWriteStream(dest)); - core13.debug("download complete"); + core14.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core13.debug("download failed"); + core14.debug("download failed"); try { yield io5.rmRF(dest); } catch (err) { - core13.debug(`Failed to delete '${dest}'. ${err.message}`); + core14.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99296,7 +99680,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core13.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core14.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core13.debug("Checking tar --version"); + core14.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99359,7 +99743,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core13.debug(versionOutput.trim()); + core14.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99367,7 +99751,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core13.isDebug() && !flags.includes("v")) { + if (core14.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99398,7 +99782,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core13.isDebug()) { + if (core14.isDebug()) { args.push("-v"); } const xarPath = yield io5.which("xar", true); @@ -99441,7 +99825,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core13.debug(`Using pwsh at path: ${pwshPath}`); + core14.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99461,7 +99845,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io5.which("powershell", true); - core13.debug(`Using powershell at path: ${powershellPath}`); + core14.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99470,7 +99854,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io5.which("unzip", true); const args = [file]; - if (!core13.isDebug()) { + if (!core14.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99481,8 +99865,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core13.debug(`Caching tool ${tool} ${version} ${arch}`); - core13.debug(`source dir: ${sourceDir}`); + core14.debug(`Caching tool ${tool} ${version} ${arch}`); + core14.debug(`source dir: ${sourceDir}`); if (!fs5.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99499,14 +99883,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core13.debug(`Caching tool ${tool} ${version} ${arch}`); - core13.debug(`source file: ${sourceFile}`); + core14.debug(`Caching tool ${tool} ${version} ${arch}`); + core14.debug(`source file: ${sourceFile}`); if (!fs5.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch); const destPath = path5.join(destFolder, targetFile); - core13.debug(`destination file ${destPath}`); + core14.debug(`destination file ${destPath}`); yield io5.cp(sourceFile, destPath); _completeToolPath(tool, version, arch); return destFolder; @@ -99529,12 +99913,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path5.join(_getCacheDirectory(), toolName, versionSpec, arch); - core13.debug(`checking cache: ${cachePath}`); + core14.debug(`checking cache: ${cachePath}`); if (fs5.existsSync(cachePath) && fs5.existsSync(`${cachePath}.complete`)) { - core13.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); toolPath = cachePath; } else { - core13.debug("not found"); + core14.debug("not found"); } } return toolPath; @@ -99563,7 +99947,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core13.debug("set auth"); + core14.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99584,7 +99968,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core13.debug("Invalid json"); + core14.debug("Invalid json"); } } return releases; @@ -99608,7 +99992,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path5.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); - core13.debug(`destination ${folderPath}`); + core14.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io5.rmRF(folderPath); yield io5.rmRF(markerPath); @@ -99620,18 +100004,18 @@ var require_tool_cache = __commonJS({ const folderPath = path5.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); const markerPath = `${folderPath}.complete`; fs5.writeFileSync(markerPath, ""); - core13.debug("finished caching tool"); + core14.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core13.debug(`isExplicit: ${c}`); + core14.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core13.debug(`explicit? ${valid3}`); + core14.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core13.debug(`evaluating ${versions.length} versions`); + core14.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -99647,9 +100031,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core13.debug(`matched: ${version}`); + core14.debug(`matched: ${version}`); } else { - core13.debug("match not found"); + core14.debug("match not found"); } return version; } @@ -100225,7 +100609,7 @@ var require_follow_redirects = __commonJS({ }); // src/resolve-environment-action.ts -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); // src/actions-util.ts var fs = __toESM(require("fs")); @@ -103125,7 +103509,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -103662,6 +104046,7 @@ function wrapCliConfigurationError(cliError) { // src/config-utils.ts var fs3 = __toESM(require("fs")); var path3 = __toESM(require("path")); +var core9 = __toESM(require_core()); // src/analyses.ts var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => { @@ -103887,6 +104272,7 @@ async function isAnalyzingDefaultBranch() { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -104034,6 +104420,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -104064,6 +104455,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -104074,16 +104470,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -104099,15 +104485,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -104168,6 +104570,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -104176,6 +104579,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -104229,7 +104633,7 @@ function appendExtraQueryExclusions(extraQueryExclusions, cliConfig) { // src/codeql.ts var fs4 = __toESM(require("fs")); var path4 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/setup-codeql.ts @@ -104244,7 +104648,7 @@ var toolcache = __toESM(require_tool_cache()); var semver6 = __toESM(require_semver2()); // src/tools-download.ts -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -104269,7 +104673,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function getCodeQL(cmd) { if (cachedCodeQL === void 0) { cachedCodeQL = await getCodeQLForCmd(cmd, true); @@ -104565,17 +104968,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -104724,12 +105123,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core10.warning( + core11.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core10.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -104848,7 +105247,7 @@ async function runResolveBuildEnvironment(cmd, logger, workingDir, language) { // src/status-report.ts var os = __toESM(require("os")); -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); function isFirstPartyAnalysis(actionName) { if (actionName !== "upload-sarif" /* UploadSarif */) { return true; @@ -104864,12 +105263,12 @@ function getActionsStatus(error3, otherFailureCause) { } function setJobStatusIfUnsuccessful(actionStatus) { if (actionStatus === "user-error") { - core11.exportVariable( + core12.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); } else if (actionStatus === "failure" || actionStatus === "aborted") { - core11.exportVariable( + core12.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_FAILURE" /* FailureStatus */ ); @@ -104888,14 +105287,14 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi let workflowStartedAt = process.env["CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */]; if (workflowStartedAt === void 0) { workflowStartedAt = actionStartedAt.toISOString(); - core11.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); + core12.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); const codeQlCliVersion = getCachedCodeQlVersion(); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { - core11.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); + core12.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); } const isSteadyStateDefaultSetupRun = process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true"; const statusReport = { @@ -104978,9 +105377,9 @@ var INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the API endpo async function sendStatusReport(statusReport) { setJobStatusIfUnsuccessful(statusReport.status); const statusReportJSON = JSON.stringify(statusReport); - core11.debug(`Sending status report: ${statusReportJSON}`); + core12.debug(`Sending status report: ${statusReportJSON}`); if (isInTestMode()) { - core11.debug("In test mode. Status reports are not uploaded."); + core12.debug("In test mode. Status reports are not uploaded."); return; } const nwo = getRepositoryNwo(); @@ -105000,28 +105399,28 @@ async function sendStatusReport(statusReport) { switch (httpError.status) { case 403: if (getWorkflowEventName() === "push" && process.env["GITHUB_ACTOR"] === "dependabot[bot]") { - core11.warning( + core12.warning( `Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading CodeQL results requires write access. To use CodeQL with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. See ${"https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push" /* SCANNING_ON_PUSH */} for more information on how to configure these events.` ); } else { - core11.warning( + core12.warning( `This run of the CodeQL Action does not have permission to access the CodeQL Action API endpoints. This could be because the Action is running on a pull request from a fork. If not, please ensure the workflow has at least the 'security-events: read' permission. Details: ${httpError.message}` ); } return; case 404: - core11.warning(httpError.message); + core12.warning(httpError.message); return; case 422: if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { - core11.debug(INCOMPATIBLE_MSG); + core12.debug(INCOMPATIBLE_MSG); } else { - core11.debug(OUT_OF_DATE_MSG); + core12.debug(OUT_OF_DATE_MSG); } return; } } - core11.warning( + core12.warning( `An unexpected error occurred when sending a status report: ${getErrorMessage( e )}` @@ -105086,16 +105485,16 @@ async function run(startedAt) { workingDirectory, getRequiredInput("language") ); - core12.setOutput(ENVIRONMENT_OUTPUT_NAME, result); + core13.setOutput(ENVIRONMENT_OUTPUT_NAME, result); } catch (unwrappedError) { const error3 = wrapError(unwrappedError); if (error3 instanceof CliError) { - core12.setOutput(ENVIRONMENT_OUTPUT_NAME, {}); + core13.setOutput(ENVIRONMENT_OUTPUT_NAME, {}); logger.warning( `Failed to resolve a build environment suitable for automatically building your code. ${error3.message}` ); } else { - core12.setFailed( + core13.setFailed( `Failed to resolve a build environment suitable for automatically building your code. ${error3.message}` ); const statusReportBase2 = await createStatusReportBase( @@ -105132,7 +105531,7 @@ async function runWrapper() { try { await run(startedAt); } catch (error3) { - core12.setFailed( + core13.setFailed( `${"resolve-environment" /* ResolveEnvironment */} action failed: ${getErrorMessage( error3 )}` diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 70871fe81f..dda7c6c5a7 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable7; + exports2.exportVariable = exportVariable8; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable7(name, val) { + function exportVariable8(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -47343,7 +47343,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -47355,23 +47355,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core14.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core15.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core14.debug(`implicitDescendants '${result.implicitDescendants}'`); + core15.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core14.debug(`matchDirectories '${result.matchDirectories}'`); + core15.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core14.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core15.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core14.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core15.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -48999,7 +48999,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs9 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path9 = __importStar2(require("path")); @@ -49052,7 +49052,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core14.debug(`Search path '${searchPath}'`); + core15.debug(`Search path '${searchPath}'`); try { yield __await2(fs9.promises.lstat(searchPath)); } catch (err) { @@ -49127,7 +49127,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core14.debug(`Broken symlink '${item.path}'`); + core15.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -49143,7 +49143,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core14.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core15.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -49246,7 +49246,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles; var crypto2 = __importStar2(require("crypto")); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs9 = __importStar2(require("fs")); var stream2 = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -49255,7 +49255,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core14.info : core14.debug; + const writeDelegate = verbose ? core15.info : core15.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -50646,7 +50646,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var exec = __importStar2(require_exec()); var glob = __importStar2(require_glob()); var io6 = __importStar2(require_io()); @@ -50697,7 +50697,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path9.relative(workspace, file).replace(new RegExp(`\\${path9.sep}`, "g"), "/"); - core14.debug(`Matched: ${relativeFile}`); + core15.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -50725,7 +50725,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core14.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core15.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -50736,10 +50736,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core14.debug(err.message); + core15.debug(err.message); } versionOutput = versionOutput.trim(); - core14.debug(versionOutput); + core15.debug(versionOutput); return versionOutput; }); } @@ -50747,7 +50747,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core14.debug(`zstd version: ${version}`); + core15.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -60530,44 +60530,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -60575,63 +60575,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -60640,16 +60640,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -60658,83 +60658,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -60748,190 +60755,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -60941,290 +61157,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; + } + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; } - function H(t2, e2, n2) { - let i2; + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; + } + function lt(t2, e2, i2) { + return pt(t2, e2, i2); + } + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -61233,172 +61484,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } + } + return i2; + } + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return s2; + return i2; } - function ot(t2) { + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -90403,7 +90787,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -90445,7 +90829,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core15.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -90502,14 +90886,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core14.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core15.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core14.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core15.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -90594,7 +90978,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -90652,9 +91036,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core14.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core15.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core14.debug(`${name} - Error is not retryable`); + core15.debug(`${name} - Error is not retryable`); break; } yield sleep(delay2); @@ -90913,7 +91297,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -90951,7 +91335,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core14.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core15.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -90985,7 +91369,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core15.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91035,7 +91419,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core14.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core15.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -91046,7 +91430,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core14.debug("Unable to validate download, no Content-Length header"); + core15.debug("Unable to validate download, no Content-Length header"); } }); } @@ -91164,7 +91548,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core14.debug("Unable to determine content length, downloading file with http-client..."); + core15.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -91254,7 +91638,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -91274,9 +91658,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core14.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core15.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -91312,12 +91696,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Download concurrency: ${result.downloadConcurrency}`); - core14.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core14.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core14.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core14.debug(`Lookup only: ${result.lookupOnly}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Download concurrency: ${result.downloadConcurrency}`); + core15.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core15.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core15.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core15.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -91511,7 +91895,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache4; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs9 = __importStar2(require("fs")); @@ -91529,7 +91913,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url = `${baseUrl}_apis/artifactcache/${resource}`; - core14.debug(`Resource Url: ${url}`); + core15.debug(`Resource Url: ${url}`); return url; } function createAcceptHeader(type2, apiVersion) { @@ -91557,7 +91941,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core14.isDebug()) { + if (core15.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -91570,9 +91954,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core14.setSecret(cacheDownloadUrl); - core14.debug(`Cache Result:`); - core14.debug(JSON.stringify(cacheResult)); + core15.setSecret(cacheDownloadUrl); + core15.debug(`Cache Result:`); + core15.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -91586,10 +91970,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core14.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core15.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core14.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core15.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -91632,7 +92016,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core14.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core15.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -91654,7 +92038,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core14.debug("Awaiting all uploads"); + core15.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -91697,16 +92081,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core14.debug("Upload cache"); + core15.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core14.debug("Commiting cache"); + core15.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core15.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core14.info("Cache saved successfully"); + core15.info("Cache saved successfully"); } }); } @@ -97189,7 +97573,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache4; exports2.saveCache = saveCache4; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var path9 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -97248,7 +97632,7 @@ var require_cache5 = __commonJS({ function restoreCache4(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -97263,8 +97647,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -97282,19 +97666,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path9.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -97302,16 +97686,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -97322,8 +97706,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -97341,30 +97725,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core14.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core15.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core14.info(`Cache hit for restore-key: ${response.matchedKey}`); + core15.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core14.info(`Cache hit for: ${response.matchedKey}`); + core15.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path9.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive path: ${archivePath}`); - core14.debug(`Starting download of archive to: ${archivePath}`); + core15.debug(`Archive path: ${archivePath}`); + core15.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core14.isDebug()) { + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -97372,9 +97756,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -97383,7 +97767,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -97392,7 +97776,7 @@ var require_cache5 = __commonJS({ function saveCache4(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -97410,26 +97794,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path9.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -97442,26 +97826,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core14.debug(`Saving Cache (ID: ${cacheId})`); + core15.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -97474,23 +97858,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path9.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -97501,16 +97885,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core14.warning(`Cache reservation failed: ${response.message}`); + core15.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core14.debug(`Failed to reserve cache: ${error3}`); + core15.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core14.debug(`Attempting to upload cache located at: ${archivePath}`); + core15.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -97518,7 +97902,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core14.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core15.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -97531,21 +97915,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core14.warning(typedError.message); + core15.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99069,7 +99453,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99092,10 +99476,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core14.info(err.message); + core15.info(err.message); } const seconds = this.getSleepAmount(); - core14.info(`Waiting ${seconds} seconds before trying again`); + core15.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99198,7 +99582,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var io6 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs9 = __importStar2(require("fs")); @@ -99227,8 +99611,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path9.join(_getTempDirectory(), crypto2.randomUUID()); yield io6.mkdirP(path9.dirname(dest)); - core14.debug(`Downloading ${url}`); - core14.debug(`Destination ${dest}`); + core15.debug(`Downloading ${url}`); + core15.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99254,7 +99638,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99263,7 +99647,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core14.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core15.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream2.pipeline); @@ -99272,16 +99656,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs9.createWriteStream(dest)); - core14.debug("download complete"); + core15.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core14.debug("download failed"); + core15.debug("download failed"); try { yield io6.rmRF(dest); } catch (err) { - core14.debug(`Failed to delete '${dest}'. ${err.message}`); + core15.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99296,7 +99680,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core14.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core15.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core14.debug("Checking tar --version"); + core15.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99359,7 +99743,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core14.debug(versionOutput.trim()); + core15.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99367,7 +99751,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core14.isDebug() && !flags.includes("v")) { + if (core15.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99398,7 +99782,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core14.isDebug()) { + if (core15.isDebug()) { args.push("-v"); } const xarPath = yield io6.which("xar", true); @@ -99441,7 +99825,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core14.debug(`Using pwsh at path: ${pwshPath}`); + core15.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99461,7 +99845,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io6.which("powershell", true); - core14.debug(`Using powershell at path: ${powershellPath}`); + core15.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99470,7 +99854,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io6.which("unzip", true); const args = [file]; - if (!core14.isDebug()) { + if (!core15.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99481,8 +99865,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os3.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch2}`); - core14.debug(`source dir: ${sourceDir}`); + core15.debug(`Caching tool ${tool} ${version} ${arch2}`); + core15.debug(`source dir: ${sourceDir}`); if (!fs9.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99499,14 +99883,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os3.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch2}`); - core14.debug(`source file: ${sourceFile}`); + core15.debug(`Caching tool ${tool} ${version} ${arch2}`); + core15.debug(`source file: ${sourceFile}`); if (!fs9.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch2); const destPath = path9.join(destFolder, targetFile); - core14.debug(`destination file ${destPath}`); + core15.debug(`destination file ${destPath}`); yield io6.cp(sourceFile, destPath); _completeToolPath(tool, version, arch2); return destFolder; @@ -99529,12 +99913,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path9.join(_getCacheDirectory(), toolName, versionSpec, arch2); - core14.debug(`checking cache: ${cachePath}`); + core15.debug(`checking cache: ${cachePath}`); if (fs9.existsSync(cachePath) && fs9.existsSync(`${cachePath}.complete`)) { - core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); + core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); toolPath = cachePath; } else { - core14.debug("not found"); + core15.debug("not found"); } } return toolPath; @@ -99563,7 +99947,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99584,7 +99968,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core14.debug("Invalid json"); + core15.debug("Invalid json"); } } return releases; @@ -99608,7 +99992,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch2) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path9.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); - core14.debug(`destination ${folderPath}`); + core15.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io6.rmRF(folderPath); yield io6.rmRF(markerPath); @@ -99620,18 +100004,18 @@ var require_tool_cache = __commonJS({ const folderPath = path9.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); const markerPath = `${folderPath}.complete`; fs9.writeFileSync(markerPath, ""); - core14.debug("finished caching tool"); + core15.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core14.debug(`isExplicit: ${c}`); + core15.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core14.debug(`explicit? ${valid3}`); + core15.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core14.debug(`evaluating ${versions.length} versions`); + core15.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -99647,9 +100031,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core14.debug(`matched: ${version}`); + core15.debug(`matched: ${version}`); } else { - core14.debug("match not found"); + core15.debug("match not found"); } return version; } @@ -100225,7 +100609,7 @@ var require_follow_redirects = __commonJS({ }); // src/setup-codeql-action.ts -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); // node_modules/uuid/dist-node/stringify.js var byteToHex = []; @@ -103222,7 +103606,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -103577,8 +103961,8 @@ var path4 = __toESM(require("path")); var semver4 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.24.3"; -var cliVersion = "2.24.3"; +var bundleVersion = "codeql-bundle-v2.25.0"; +var cliVersion = "2.25.0"; // src/overlay/index.ts var fs3 = __toESM(require("fs")); @@ -103780,6 +104164,7 @@ function formatDuration(durationMs) { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -103930,6 +104315,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -103960,6 +104350,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -103970,16 +104365,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -103995,15 +104380,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -104375,7 +104776,7 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) { } // src/init.ts -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); var toolrunner4 = __toESM(require_toolrunner()); var github2 = __toESM(require_github()); var io5 = __toESM(require_io()); @@ -104383,7 +104784,7 @@ var io5 = __toESM(require_io()); // src/codeql.ts var fs8 = __toESM(require("fs")); var path8 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -104628,6 +105029,9 @@ function wrapCliConfigurationError(cliError) { return new ConfigurationError(errorMessageBuilder); } +// src/config-utils.ts +var core9 = __toESM(require_core()); + // src/analyses.ts var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => { AnalysisKind2["CodeScanning"] = "code-scanning"; @@ -104732,6 +105136,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -104740,6 +105145,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -104936,7 +105342,7 @@ var fs6 = __toESM(require("fs")); var os = __toESM(require("os")); var path6 = __toESM(require("path")); var import_perf_hooks = require("perf_hooks"); -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -104990,10 +105396,10 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat }; } } catch (e) { - core9.warning( + core10.warning( `Failed to download and extract CodeQL bundle using streaming with error: ${getErrorMessage(e)}` ); - core9.warning(`Falling back to downloading the bundle before extracting.`); + core10.warning(`Falling back to downloading the bundle before extracting.`); await cleanUpPath(dest, "CodeQL bundle", logger); } const toolsDownloadStart = import_perf_hooks.performance.now(); @@ -105675,7 +106081,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, checkVersion) { try { const { @@ -106013,17 +106418,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -106172,12 +106573,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core10.warning( + core11.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core10.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -106314,7 +106715,7 @@ async function initCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVe // src/status-report.ts var os2 = __toESM(require("os")); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); function isFirstPartyAnalysis(actionName) { if (actionName !== "upload-sarif" /* UploadSarif */) { return true; @@ -106330,12 +106731,12 @@ function getActionsStatus(error3, otherFailureCause) { } function setJobStatusIfUnsuccessful(actionStatus) { if (actionStatus === "user-error") { - core12.exportVariable( + core13.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); } else if (actionStatus === "failure" || actionStatus === "aborted") { - core12.exportVariable( + core13.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_FAILURE" /* FailureStatus */ ); @@ -106354,14 +106755,14 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi let workflowStartedAt = process.env["CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */]; if (workflowStartedAt === void 0) { workflowStartedAt = actionStartedAt.toISOString(); - core12.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); + core13.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); const codeQlCliVersion = getCachedCodeQlVersion(); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { - core12.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); + core13.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); } const isSteadyStateDefaultSetupRun = process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true"; const statusReport = { @@ -106444,9 +106845,9 @@ var INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the API endpo async function sendStatusReport(statusReport) { setJobStatusIfUnsuccessful(statusReport.status); const statusReportJSON = JSON.stringify(statusReport); - core12.debug(`Sending status report: ${statusReportJSON}`); + core13.debug(`Sending status report: ${statusReportJSON}`); if (isInTestMode()) { - core12.debug("In test mode. Status reports are not uploaded."); + core13.debug("In test mode. Status reports are not uploaded."); return; } const nwo = getRepositoryNwo(); @@ -106466,28 +106867,28 @@ async function sendStatusReport(statusReport) { switch (httpError.status) { case 403: if (getWorkflowEventName() === "push" && process.env["GITHUB_ACTOR"] === "dependabot[bot]") { - core12.warning( + core13.warning( `Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading CodeQL results requires write access. To use CodeQL with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. See ${"https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push" /* SCANNING_ON_PUSH */} for more information on how to configure these events.` ); } else { - core12.warning( + core13.warning( `This run of the CodeQL Action does not have permission to access the CodeQL Action API endpoints. This could be because the Action is running on a pull request from a fork. If not, please ensure the workflow has at least the 'security-events: read' permission. Details: ${httpError.message}` ); } return; case 404: - core12.warning(httpError.message); + core13.warning(httpError.message); return; case 422: if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { - core12.debug(INCOMPATIBLE_MSG); + core13.debug(INCOMPATIBLE_MSG); } else { - core12.debug(OUT_OF_DATE_MSG); + core13.debug(OUT_OF_DATE_MSG); } return; } } - core12.warning( + core13.warning( `An unexpected error occurred when sending a status report: ${getErrorMessage( e )}` @@ -106577,7 +106978,7 @@ async function run(startedAt) { ); const jobRunUuid = v4_default(); logger.info(`Job run UUID is ${jobRunUuid}.`); - core13.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid); + core14.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid); const statusReportBase = await createStatusReportBase( "setup-codeql" /* SetupCodeQL */, "starting", @@ -106606,12 +107007,12 @@ async function run(startedAt) { toolsDownloadStatusReport = initCodeQLResult.toolsDownloadStatusReport; toolsVersion = initCodeQLResult.toolsVersion; toolsSource = initCodeQLResult.toolsSource; - core13.setOutput("codeql-path", codeql.getPath()); - core13.setOutput("codeql-version", (await codeql.getVersion()).version); - core13.exportVariable("CODEQL_ACTION_SETUP_CODEQL_HAS_RUN" /* SETUP_CODEQL_ACTION_HAS_RUN */, "true"); + core14.setOutput("codeql-path", codeql.getPath()); + core14.setOutput("codeql-version", (await codeql.getVersion()).version); + core14.exportVariable("CODEQL_ACTION_SETUP_CODEQL_HAS_RUN" /* SETUP_CODEQL_ACTION_HAS_RUN */, "true"); } catch (unwrappedError) { const error3 = wrapError(unwrappedError); - core13.setFailed(error3.message); + core14.setFailed(error3.message); const statusReportBase = await createStatusReportBase( "setup-codeql" /* SetupCodeQL */, error3 instanceof ConfigurationError ? "user-error" : "failure", @@ -106642,7 +107043,7 @@ async function runWrapper() { try { await run(startedAt); } catch (error3) { - core13.setFailed(`setup-codeql action failed: ${getErrorMessage(error3)}`); + core14.setFailed(`setup-codeql action failed: ${getErrorMessage(error3)}`); await sendUnhandledErrorStatusReport( "setup-codeql" /* SetupCodeQL */, startedAt, diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index 4d5f78bf7f..87465e231a 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable6; + exports2.exportVariable = exportVariable7; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable6(name, val) { + function exportVariable7(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -48640,7 +48640,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -48652,23 +48652,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core14.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core15.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core14.debug(`implicitDescendants '${result.implicitDescendants}'`); + core15.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core14.debug(`matchDirectories '${result.matchDirectories}'`); + core15.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core14.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core15.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core14.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core15.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -50296,7 +50296,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs3 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path4 = __importStar2(require("path")); @@ -50349,7 +50349,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core14.debug(`Search path '${searchPath}'`); + core15.debug(`Search path '${searchPath}'`); try { yield __await2(fs3.promises.lstat(searchPath)); } catch (err) { @@ -50424,7 +50424,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core14.debug(`Broken symlink '${item.path}'`); + core15.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -50440,7 +50440,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core14.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core15.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -50543,7 +50543,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles2; var crypto2 = __importStar2(require("crypto")); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs3 = __importStar2(require("fs")); var stream = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -50552,7 +50552,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core14.info : core14.debug; + const writeDelegate = verbose ? core15.info : core15.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -51943,7 +51943,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var exec3 = __importStar2(require_exec()); var glob2 = __importStar2(require_glob()); var io6 = __importStar2(require_io()); @@ -51994,7 +51994,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path4.relative(workspace, file).replace(new RegExp(`\\${path4.sep}`, "g"), "/"); - core14.debug(`Matched: ${relativeFile}`); + core15.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -52022,7 +52022,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core14.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core15.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec3.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -52033,10 +52033,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core14.debug(err.message); + core15.debug(err.message); } versionOutput = versionOutput.trim(); - core14.debug(versionOutput); + core15.debug(versionOutput); return versionOutput; }); } @@ -52044,7 +52044,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core14.debug(`zstd version: ${version}`); + core15.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -61827,44 +61827,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -61872,63 +61872,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61937,16 +61937,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61955,83 +61955,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62045,190 +62052,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _2(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _2(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _2(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _2(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _2 = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _2), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -62238,290 +62454,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + } + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - function H(t2, e2, n2) { - let i2; + function lt(t2, e2, i2) { + return pt(t2, e2, i2); + } + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62530,172 +62781,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } } - return s2; + return i2; } - function ot(t2) { + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + } + return i2; + } + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -91700,7 +92084,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -91742,7 +92126,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core15.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91799,14 +92183,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core14.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core15.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core14.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core15.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -91891,7 +92275,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -91949,9 +92333,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core14.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core15.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core14.debug(`${name} - Error is not retryable`); + core15.debug(`${name} - Error is not retryable`); break; } yield sleep(delay); @@ -92210,7 +92594,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -92248,7 +92632,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core14.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core15.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -92282,7 +92666,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core15.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -92332,7 +92716,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core14.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core15.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -92343,7 +92727,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core14.debug("Unable to validate download, no Content-Length header"); + core15.debug("Unable to validate download, no Content-Length header"); } }); } @@ -92461,7 +92845,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core14.debug("Unable to determine content length, downloading file with http-client..."); + core15.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -92551,7 +92935,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -92571,9 +92955,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core14.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core15.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -92609,12 +92993,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Download concurrency: ${result.downloadConcurrency}`); - core14.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core14.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core14.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core14.debug(`Lookup only: ${result.lookupOnly}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Download concurrency: ${result.downloadConcurrency}`); + core15.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core15.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core15.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core15.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -92808,7 +93192,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache5; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs3 = __importStar2(require("fs")); @@ -92826,7 +93210,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url = `${baseUrl}_apis/artifactcache/${resource}`; - core14.debug(`Resource Url: ${url}`); + core15.debug(`Resource Url: ${url}`); return url; } function createAcceptHeader(type2, apiVersion) { @@ -92854,7 +93238,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core14.isDebug()) { + if (core15.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -92867,9 +93251,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core14.setSecret(cacheDownloadUrl); - core14.debug(`Cache Result:`); - core14.debug(JSON.stringify(cacheResult)); + core15.setSecret(cacheDownloadUrl); + core15.debug(`Cache Result:`); + core15.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -92883,10 +93267,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core14.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core15.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core14.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core15.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -92929,7 +93313,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core14.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core15.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -92951,7 +93335,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core14.debug("Awaiting all uploads"); + core15.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -92994,16 +93378,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core14.debug("Upload cache"); + core15.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core14.debug("Commiting cache"); + core15.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core15.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core14.info("Cache saved successfully"); + core15.info("Cache saved successfully"); } }); } @@ -98486,7 +98870,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache5; exports2.saveCache = saveCache5; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var path4 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -98545,7 +98929,7 @@ var require_cache5 = __commonJS({ function restoreCache5(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -98560,8 +98944,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98579,19 +98963,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path4.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -98599,16 +98983,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98619,8 +99003,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98638,30 +99022,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core14.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core15.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core14.info(`Cache hit for restore-key: ${response.matchedKey}`); + core15.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core14.info(`Cache hit for: ${response.matchedKey}`); + core15.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path4.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive path: ${archivePath}`); - core14.debug(`Starting download of archive to: ${archivePath}`); + core15.debug(`Archive path: ${archivePath}`); + core15.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core14.isDebug()) { + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -98669,9 +99053,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -98680,7 +99064,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98689,7 +99073,7 @@ var require_cache5 = __commonJS({ function saveCache5(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -98707,26 +99091,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path4.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -98739,26 +99123,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core14.debug(`Saving Cache (ID: ${cacheId})`); + core15.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -98771,23 +99155,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path4.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -98798,16 +99182,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core14.warning(`Cache reservation failed: ${response.message}`); + core15.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core14.debug(`Failed to reserve cache: ${error3}`); + core15.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core14.debug(`Attempting to upload cache located at: ${archivePath}`); + core15.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -98815,7 +99199,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core14.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core15.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -98828,21 +99212,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core14.warning(typedError.message); + core15.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -100958,14 +101342,14 @@ var require_retention = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getExpiration = void 0; var generated_1 = require_generated(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getExpiration(retentionDays) { if (!retentionDays) { return void 0; } const maxRetentionDays = getRetentionDays(); if (maxRetentionDays && maxRetentionDays < retentionDays) { - core14.warning(`Retention days cannot be greater than the maximum allowed retention set within the repository. Using ${maxRetentionDays} instead.`); + core15.warning(`Retention days cannot be greater than the maximum allowed retention set within the repository. Using ${maxRetentionDays} instead.`); retentionDays = maxRetentionDays; } const expirationDate = /* @__PURE__ */ new Date(); @@ -101303,7 +101687,7 @@ var require_util19 = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.maskSecretUrls = exports2.maskSigUrl = exports2.getBackendIdsFromToken = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var config_1 = require_config2(); var jwt_decode_1 = __importDefault2(require_jwt_decode_cjs()); var core_1 = require_core(); @@ -101330,8 +101714,8 @@ var require_util19 = __commonJS({ workflowRunBackendId: scopeParts[1], workflowJobRunBackendId: scopeParts[2] }; - core14.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); - core14.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); + core15.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); + core15.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); return ids; } throw InvalidJwtError; @@ -101691,7 +102075,7 @@ var require_blob_upload = __commonJS({ exports2.uploadZipToBlobStorage = void 0; var storage_blob_1 = require_commonjs15(); var config_1 = require_config2(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var crypto2 = __importStar2(require("crypto")); var stream = __importStar2(require("stream")); var errors_1 = require_errors4(); @@ -101717,9 +102101,9 @@ var require_blob_upload = __commonJS({ const bufferSize = (0, config_1.getUploadChunkSize)(); const blobClient = new storage_blob_1.BlobClient(authenticatedUploadURL); const blockBlobClient = blobClient.getBlockBlobClient(); - core14.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`); + core15.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`); const uploadCallback = (progress) => { - core14.info(`Uploaded bytes ${progress.loadedBytes}`); + core15.info(`Uploaded bytes ${progress.loadedBytes}`); uploadByteCount = progress.loadedBytes; lastProgressTime = Date.now(); }; @@ -101733,7 +102117,7 @@ var require_blob_upload = __commonJS({ const hashStream = crypto2.createHash("sha256"); zipUploadStream.pipe(uploadStream); zipUploadStream.pipe(hashStream).setEncoding("hex"); - core14.info("Beginning upload of artifact content to blob storage"); + core15.info("Beginning upload of artifact content to blob storage"); try { yield Promise.race([ blockBlobClient.uploadStream(uploadStream, bufferSize, maxConcurrency, options), @@ -101747,12 +102131,12 @@ var require_blob_upload = __commonJS({ } finally { abortController.abort(); } - core14.info("Finished uploading artifact content to blob storage!"); + core15.info("Finished uploading artifact content to blob storage!"); hashStream.end(); sha256Hash = hashStream.read(); - core14.info(`SHA256 digest of uploaded artifact zip is ${sha256Hash}`); + core15.info(`SHA256 digest of uploaded artifact zip is ${sha256Hash}`); if (uploadByteCount === 0) { - core14.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`); + core15.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`); } return { uploadSize: uploadByteCount, @@ -127093,7 +127477,7 @@ var require_zip2 = __commonJS({ var stream = __importStar2(require("stream")); var promises_1 = require("fs/promises"); var archiver2 = __importStar2(require_archiver()); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var config_1 = require_config2(); exports2.DEFAULT_COMPRESSION_LEVEL = 6; var ZipUploadStream = class extends stream.Transform { @@ -127110,7 +127494,7 @@ var require_zip2 = __commonJS({ exports2.ZipUploadStream = ZipUploadStream; function createZipUploadStream(uploadSpecification_1) { return __awaiter2(this, arguments, void 0, function* (uploadSpecification, compressionLevel = exports2.DEFAULT_COMPRESSION_LEVEL) { - core14.debug(`Creating Artifact archive with compressionLevel: ${compressionLevel}`); + core15.debug(`Creating Artifact archive with compressionLevel: ${compressionLevel}`); const zip = archiver2.create("zip", { highWaterMark: (0, config_1.getUploadChunkSize)(), zlib: { level: compressionLevel } @@ -127134,8 +127518,8 @@ var require_zip2 = __commonJS({ } const bufferSize = (0, config_1.getUploadChunkSize)(); const zipUploadStream = new ZipUploadStream(bufferSize); - core14.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`); - core14.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`); + core15.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`); + core15.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`); zip.pipe(zipUploadStream); zip.finalize(); return zipUploadStream; @@ -127143,24 +127527,24 @@ var require_zip2 = __commonJS({ } exports2.createZipUploadStream = createZipUploadStream; var zipErrorCallback = (error3) => { - core14.error("An error has occurred while creating the zip file for upload"); - core14.info(error3); + core15.error("An error has occurred while creating the zip file for upload"); + core15.info(error3); throw new Error("An error has occurred during zip creation for the artifact"); }; var zipWarningCallback = (error3) => { if (error3.code === "ENOENT") { - core14.warning("ENOENT warning during artifact zip creation. No such file or directory"); - core14.info(error3); + core15.warning("ENOENT warning during artifact zip creation. No such file or directory"); + core15.info(error3); } else { - core14.warning(`A non-blocking warning has occurred during artifact zip creation: ${error3.code}`); - core14.info(error3); + core15.warning(`A non-blocking warning has occurred during artifact zip creation: ${error3.code}`); + core15.info(error3); } }; var zipFinishCallback = () => { - core14.debug("Zip stream for upload has finished."); + core15.debug("Zip stream for upload has finished."); }; var zipEndCallback = () => { - core14.debug("Zip stream for upload has ended."); + core15.debug("Zip stream for upload has ended."); }; } }); @@ -127225,7 +127609,7 @@ var require_upload_artifact = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.uploadArtifact = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var retention_1 = require_retention(); var path_and_artifact_name_validation_1 = require_path_and_artifact_name_validation(); var artifact_twirp_client_1 = require_artifact_twirp_client2(); @@ -127272,13 +127656,13 @@ var require_upload_artifact = __commonJS({ value: `sha256:${uploadResult.sha256Hash}` }); } - core14.info(`Finalizing artifact upload`); + core15.info(`Finalizing artifact upload`); const finalizeArtifactResp = yield artifactClient.FinalizeArtifact(finalizeArtifactReq); if (!finalizeArtifactResp.ok) { throw new errors_1.InvalidResponseError("FinalizeArtifact: response from backend was not ok"); } const artifactId = BigInt(finalizeArtifactResp.artifactId); - core14.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`); + core15.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`); return { size: uploadResult.uploadSize, digest: uploadResult.sha256Hash, @@ -150759,7 +151143,7 @@ var require_download_artifact = __commonJS({ var crypto2 = __importStar2(require("crypto")); var stream = __importStar2(require("stream")); var github2 = __importStar2(require_github2()); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var httpClient = __importStar2(require_lib()); var unzip_stream_1 = __importDefault2(require_unzip()); var user_agent_1 = require_user_agent2(); @@ -150795,7 +151179,7 @@ var require_download_artifact = __commonJS({ return yield streamExtractExternal(url, directory); } catch (error3) { retryCount++; - core14.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); + core15.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); yield new Promise((resolve3) => setTimeout(resolve3, 5e3)); } } @@ -150825,7 +151209,7 @@ var require_download_artifact = __commonJS({ extractStream.on("data", () => { timer.refresh(); }).on("error", (error3) => { - core14.debug(`response.message: Artifact download failed: ${error3.message}`); + core15.debug(`response.message: Artifact download failed: ${error3.message}`); clearTimeout(timer); reject(error3); }).pipe(unzip_stream_1.default.Extract({ path: directory })).on("close", () => { @@ -150833,7 +151217,7 @@ var require_download_artifact = __commonJS({ if (hashStream) { hashStream.end(); sha256Digest = hashStream.read(); - core14.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); + core15.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); } resolve3({ sha256Digest: `sha256:${sha256Digest}` }); }).on("error", (error3) => { @@ -150848,7 +151232,7 @@ var require_download_artifact = __commonJS({ const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path); const api = github2.getOctokit(token); let digestMismatch = false; - core14.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`); + core15.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`); const { headers, status } = yield api.rest.actions.downloadArtifact({ owner: repositoryOwner, repo: repositoryName, @@ -150865,16 +151249,16 @@ var require_download_artifact = __commonJS({ if (!location) { throw new Error(`Unable to redirect to artifact download url`); } - core14.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`); + core15.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`); try { - core14.info(`Starting download of artifact to: ${downloadPath}`); + core15.info(`Starting download of artifact to: ${downloadPath}`); const extractResponse = yield streamExtract(location, downloadPath); - core14.info(`Artifact download completed successfully.`); + core15.info(`Artifact download completed successfully.`); if (options === null || options === void 0 ? void 0 : options.expectedHash) { if ((options === null || options === void 0 ? void 0 : options.expectedHash) !== extractResponse.sha256Digest) { digestMismatch = true; - core14.debug(`Computed digest: ${extractResponse.sha256Digest}`); - core14.debug(`Expected digest: ${options.expectedHash}`); + core15.debug(`Computed digest: ${extractResponse.sha256Digest}`); + core15.debug(`Expected digest: ${options.expectedHash}`); } } } catch (error3) { @@ -150901,7 +151285,7 @@ var require_download_artifact = __commonJS({ Are you trying to download from a different run? Try specifying a github-token with \`actions:read\` scope.`); } if (artifacts.length > 1) { - core14.warning("Multiple artifacts found, defaulting to first."); + core15.warning("Multiple artifacts found, defaulting to first."); } const signedReq = { workflowRunBackendId: artifacts[0].workflowRunBackendId, @@ -150909,16 +151293,16 @@ Are you trying to download from a different run? Try specifying a github-token w name: artifacts[0].name }; const { signedUrl } = yield artifactClient.GetSignedArtifactURL(signedReq); - core14.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`); + core15.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`); try { - core14.info(`Starting download of artifact to: ${downloadPath}`); + core15.info(`Starting download of artifact to: ${downloadPath}`); const extractResponse = yield streamExtract(signedUrl, downloadPath); - core14.info(`Artifact download completed successfully.`); + core15.info(`Artifact download completed successfully.`); if (options === null || options === void 0 ? void 0 : options.expectedHash) { if ((options === null || options === void 0 ? void 0 : options.expectedHash) !== extractResponse.sha256Digest) { digestMismatch = true; - core14.debug(`Computed digest: ${extractResponse.sha256Digest}`); - core14.debug(`Expected digest: ${options.expectedHash}`); + core15.debug(`Computed digest: ${extractResponse.sha256Digest}`); + core15.debug(`Expected digest: ${options.expectedHash}`); } } } catch (error3) { @@ -150931,10 +151315,10 @@ Are you trying to download from a different run? Try specifying a github-token w function resolveOrCreateDirectory() { return __awaiter2(this, arguments, void 0, function* (downloadPath = (0, config_1.getGitHubWorkspaceDir)()) { if (!(yield exists(downloadPath))) { - core14.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`); + core15.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`); yield promises_1.default.mkdir(downloadPath, { recursive: true }); } else { - core14.debug(`Artifact destination folder already exists: ${downloadPath}`); + core15.debug(`Artifact destination folder already exists: ${downloadPath}`); } return downloadPath; }); @@ -150975,7 +151359,7 @@ var require_retry_options = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getRetryOptions = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var defaultMaxRetryNumber = 5; var defaultExemptStatusCodes = [400, 401, 403, 404, 422]; function getRetryOptions(defaultOptions, retries = defaultMaxRetryNumber, exemptStatusCodes = defaultExemptStatusCodes) { @@ -150990,7 +151374,7 @@ var require_retry_options = __commonJS({ retryOptions.doNotRetry = exemptStatusCodes; } const requestOptions = Object.assign(Object.assign({}, defaultOptions.request), { retries }); - core14.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : "octokit default: [400, 401, 403, 404, 422]"})`); + core15.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : "octokit default: [400, 401, 403, 404, 422]"})`); return [retryOptions, requestOptions]; } exports2.getRetryOptions = getRetryOptions; @@ -151147,7 +151531,7 @@ var require_get_artifact = __commonJS({ exports2.getArtifactInternal = exports2.getArtifactPublic = void 0; var github_1 = require_github2(); var plugin_retry_1 = require_dist_node12(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var utils_1 = require_utils11(); var retry_options_1 = require_retry_options(); var plugin_request_log_1 = require_dist_node11(); @@ -151185,7 +151569,7 @@ var require_get_artifact = __commonJS({ let artifact2 = getArtifactResp.data.artifacts[0]; if (getArtifactResp.data.artifacts.length > 1) { artifact2 = getArtifactResp.data.artifacts.sort((a, b) => b.id - a.id)[0]; - core14.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.id})`); + core15.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.id})`); } return { artifact: { @@ -151218,7 +151602,7 @@ var require_get_artifact = __commonJS({ let artifact2 = res.artifacts[0]; if (res.artifacts.length > 1) { artifact2 = res.artifacts.sort((a, b) => Number(b.databaseId) - Number(a.databaseId))[0]; - core14.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.databaseId})`); + core15.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.databaseId})`); } return { artifact: { @@ -154326,7 +154710,7 @@ var require_core3 = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable6(name, val) { + function exportVariable7(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -154335,7 +154719,7 @@ var require_core3 = __commonJS({ } (0, command_1.issueCommand)("set-env", { name }, convertedVal); } - exports2.exportVariable = exportVariable6; + exports2.exportVariable = exportVariable7; function setSecret(secret) { (0, command_1.issueCommand)("add-mask", {}, secret); } @@ -155956,7 +156340,7 @@ var require_requestUtils2 = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.retryHttpClientRequest = exports2.retry = void 0; var utils_1 = require_utils13(); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var config_variables_1 = require_config_variables(); function retry2(name, operation, customErrorMessages, maxAttempts) { return __awaiter2(this, void 0, void 0, function* () { @@ -155983,13 +156367,13 @@ var require_requestUtils2 = __commonJS({ errorMessage = error3.message; } if (!isRetryable) { - core14.info(`${name} - Error is not retryable`); + core15.info(`${name} - Error is not retryable`); if (response) { (0, utils_1.displayHttpDiagnostics)(response); } break; } - core14.info(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core15.info(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); yield (0, utils_1.sleep)((0, utils_1.getExponentialRetryTimeInMilliseconds)(attempt)); attempt++; } @@ -156073,7 +156457,7 @@ var require_upload_http_client = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadHttpClient = void 0; var fs3 = __importStar2(require("fs")); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var tmp = __importStar2(require_tmp_promise()); var stream = __importStar2(require("stream")); var utils_1 = require_utils13(); @@ -156138,7 +156522,7 @@ var require_upload_http_client = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const FILE_CONCURRENCY = (0, config_variables_1.getUploadFileConcurrency)(); const MAX_CHUNK_SIZE = (0, config_variables_1.getUploadChunkSize)(); - core14.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`); + core15.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`); const parameters = []; let continueOnError = true; if (options) { @@ -156175,15 +156559,15 @@ var require_upload_http_client = __commonJS({ } const startTime = perf_hooks_1.performance.now(); const uploadFileResult = yield this.uploadFileAsync(index, currentFileParameters); - if (core14.isDebug()) { - core14.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`); + if (core15.isDebug()) { + core15.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`); } uploadFileSize += uploadFileResult.successfulUploadSize; totalFileSize += uploadFileResult.totalSize; if (uploadFileResult.isSuccess === false) { failedItemsToReport.push(currentFileParameters.file); if (!continueOnError) { - core14.error(`aborting artifact upload`); + core15.error(`aborting artifact upload`); abortPendingFileUploads = true; } } @@ -156192,7 +156576,7 @@ var require_upload_http_client = __commonJS({ }))); this.statusReporter.stop(); this.uploadHttpManager.disposeAndReplaceAllClients(); - core14.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`); + core15.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`); return { uploadSize: uploadFileSize, totalSize: totalFileSize, @@ -156218,16 +156602,16 @@ var require_upload_http_client = __commonJS({ let uploadFileSize = 0; let isGzip = true; if (!isFIFO && totalFileSize < 65536) { - core14.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`); + core15.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`); const buffer = yield (0, upload_gzip_1.createGZipFileInBuffer)(parameters.file); let openUploadStream; if (totalFileSize < buffer.byteLength) { - core14.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); + core15.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); openUploadStream = () => fs3.createReadStream(parameters.file); isGzip = false; uploadFileSize = totalFileSize; } else { - core14.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`); + core15.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`); openUploadStream = () => { const passThrough = new stream.PassThrough(); passThrough.end(buffer); @@ -156239,7 +156623,7 @@ var require_upload_http_client = __commonJS({ if (!result) { isUploadSuccessful = false; failedChunkSizes += uploadFileSize; - core14.warning(`Aborting upload for ${parameters.file} due to failure`); + core15.warning(`Aborting upload for ${parameters.file} due to failure`); } return { isSuccess: isUploadSuccessful, @@ -156248,16 +156632,16 @@ var require_upload_http_client = __commonJS({ }; } else { const tempFile = yield tmp.file(); - core14.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`); + core15.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`); uploadFileSize = yield (0, upload_gzip_1.createGZipFileOnDisk)(parameters.file, tempFile.path); let uploadFilePath = tempFile.path; if (!isFIFO && totalFileSize < uploadFileSize) { - core14.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); + core15.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); uploadFileSize = totalFileSize; uploadFilePath = parameters.file; isGzip = false; } else { - core14.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`); + core15.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`); } let abortFileUpload = false; while (offset < uploadFileSize) { @@ -156277,7 +156661,7 @@ var require_upload_http_client = __commonJS({ if (!result) { isUploadSuccessful = false; failedChunkSizes += chunkSize; - core14.warning(`Aborting upload for ${parameters.file} due to failure`); + core15.warning(`Aborting upload for ${parameters.file} due to failure`); abortFileUpload = true; } else { if (uploadFileSize > 8388608) { @@ -156285,7 +156669,7 @@ var require_upload_http_client = __commonJS({ } } } - core14.debug(`deleting temporary gzip file ${tempFile.path}`); + core15.debug(`deleting temporary gzip file ${tempFile.path}`); yield tempFile.cleanup(); return { isSuccess: isUploadSuccessful, @@ -156324,7 +156708,7 @@ var require_upload_http_client = __commonJS({ if (response) { (0, utils_1.displayHttpDiagnostics)(response); } - core14.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`); + core15.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`); return true; } return false; @@ -156332,14 +156716,14 @@ var require_upload_http_client = __commonJS({ const backOff = (retryAfterValue) => __awaiter2(this, void 0, void 0, function* () { this.uploadHttpManager.disposeAndReplaceClient(httpClientIndex); if (retryAfterValue) { - core14.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`); + core15.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`); yield (0, utils_1.sleep)(retryAfterValue); } else { const backoffTime = (0, utils_1.getExponentialRetryTimeInMilliseconds)(retryCount); - core14.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`); + core15.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`); yield (0, utils_1.sleep)(backoffTime); } - core14.info(`Finished backoff for retry #${retryCount}, continuing with upload`); + core15.info(`Finished backoff for retry #${retryCount}, continuing with upload`); return; }); while (retryCount <= retryLimit) { @@ -156347,7 +156731,7 @@ var require_upload_http_client = __commonJS({ try { response = yield uploadChunkRequest(); } catch (error3) { - core14.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`); + core15.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`); console.log(error3); if (incrementAndCheckRetryLimit()) { return false; @@ -156359,13 +156743,13 @@ var require_upload_http_client = __commonJS({ if ((0, utils_1.isSuccessStatusCode)(response.message.statusCode)) { return true; } else if ((0, utils_1.isRetryableStatusCode)(response.message.statusCode)) { - core14.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`); + core15.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`); if (incrementAndCheckRetryLimit(response)) { return false; } (0, utils_1.isThrottledStatusCode)(response.message.statusCode) ? yield backOff((0, utils_1.tryGetRetryAfterValueTimeInMilliseconds)(response.message.headers)) : yield backOff(); } else { - core14.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`); + core15.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`); (0, utils_1.displayHttpDiagnostics)(response); return false; } @@ -156383,7 +156767,7 @@ var require_upload_http_client = __commonJS({ resourceUrl.searchParams.append("artifactName", artifactName); const parameters = { Size: size }; const data = JSON.stringify(parameters, null, 2); - core14.debug(`URL is ${resourceUrl.toString()}`); + core15.debug(`URL is ${resourceUrl.toString()}`); const client = this.uploadHttpManager.getClient(0); const headers = (0, utils_1.getUploadHeaders)("application/json", false); const customErrorMessages = /* @__PURE__ */ new Map([ @@ -156396,7 +156780,7 @@ var require_upload_http_client = __commonJS({ return client.patch(resourceUrl.toString(), data, headers); }), customErrorMessages); yield response.readBody(); - core14.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`); + core15.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`); }); } }; @@ -156465,7 +156849,7 @@ var require_download_http_client = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DownloadHttpClient = void 0; var fs3 = __importStar2(require("fs")); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var zlib = __importStar2(require("zlib")); var utils_1 = require_utils13(); var url_1 = require("url"); @@ -156519,11 +156903,11 @@ var require_download_http_client = __commonJS({ downloadSingleArtifact(downloadItems) { return __awaiter2(this, void 0, void 0, function* () { const DOWNLOAD_CONCURRENCY = (0, config_variables_1.getDownloadFileConcurrency)(); - core14.debug(`Download file concurrency is set to ${DOWNLOAD_CONCURRENCY}`); + core15.debug(`Download file concurrency is set to ${DOWNLOAD_CONCURRENCY}`); const parallelDownloads = [...new Array(DOWNLOAD_CONCURRENCY).keys()]; let currentFile = 0; let downloadedFiles = 0; - core14.info(`Total number of files that will be downloaded: ${downloadItems.length}`); + core15.info(`Total number of files that will be downloaded: ${downloadItems.length}`); this.statusReporter.setTotalNumberOfFilesToProcess(downloadItems.length); this.statusReporter.start(); yield Promise.all(parallelDownloads.map((index) => __awaiter2(this, void 0, void 0, function* () { @@ -156532,8 +156916,8 @@ var require_download_http_client = __commonJS({ currentFile += 1; const startTime = perf_hooks_1.performance.now(); yield this.downloadIndividualFile(index, currentFileToDownload.sourceLocation, currentFileToDownload.targetPath); - if (core14.isDebug()) { - core14.debug(`File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish downloading`); + if (core15.isDebug()) { + core15.debug(`File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish downloading`); } this.statusReporter.incrementProcessedCount(); } @@ -156571,19 +156955,19 @@ var require_download_http_client = __commonJS({ } else { this.downloadHttpManager.disposeAndReplaceClient(httpClientIndex); if (retryAfterValue) { - core14.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the download`); + core15.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the download`); yield (0, utils_1.sleep)(retryAfterValue); } else { const backoffTime = (0, utils_1.getExponentialRetryTimeInMilliseconds)(retryCount); - core14.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the download`); + core15.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the download`); yield (0, utils_1.sleep)(backoffTime); } - core14.info(`Finished backoff for retry #${retryCount}, continuing with download`); + core15.info(`Finished backoff for retry #${retryCount}, continuing with download`); } }); const isAllBytesReceived = (expected, received) => { if (!expected || !received || process.env["ACTIONS_ARTIFACT_SKIP_DOWNLOAD_VALIDATION"]) { - core14.info("Skipping download validation."); + core15.info("Skipping download validation."); return true; } return parseInt(expected) === received; @@ -156604,7 +156988,7 @@ var require_download_http_client = __commonJS({ try { response = yield makeDownloadRequest(); } catch (error3) { - core14.info("An error occurred while attempting to download a file"); + core15.info("An error occurred while attempting to download a file"); console.log(error3); yield backOff(); continue; @@ -156624,7 +157008,7 @@ var require_download_http_client = __commonJS({ } } if (forceRetry || (0, utils_1.isRetryableStatusCode)(response.message.statusCode)) { - core14.info(`A ${response.message.statusCode} response code has been received while attempting to download an artifact`); + core15.info(`A ${response.message.statusCode} response code has been received while attempting to download an artifact`); resetDestinationStream(downloadPath); (0, utils_1.isThrottledStatusCode)(response.message.statusCode) ? yield backOff((0, utils_1.tryGetRetryAfterValueTimeInMilliseconds)(response.message.headers)) : yield backOff(); } else { @@ -156646,29 +157030,29 @@ var require_download_http_client = __commonJS({ if (isGzip) { const gunzip = zlib.createGunzip(); response.message.on("error", (error3) => { - core14.info(`An error occurred while attempting to read the response stream`); + core15.info(`An error occurred while attempting to read the response stream`); gunzip.close(); destinationStream.close(); reject(error3); }).pipe(gunzip).on("error", (error3) => { - core14.info(`An error occurred while attempting to decompress the response stream`); + core15.info(`An error occurred while attempting to decompress the response stream`); destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { resolve3(); }).on("error", (error3) => { - core14.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); + core15.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); }); } else { response.message.on("error", (error3) => { - core14.info(`An error occurred while attempting to read the response stream`); + core15.info(`An error occurred while attempting to read the response stream`); destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { resolve3(); }).on("error", (error3) => { - core14.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); + core15.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); }); } @@ -156807,7 +157191,7 @@ var require_artifact_client = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultArtifactClient = void 0; - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var upload_specification_1 = require_upload_specification(); var upload_http_client_1 = require_upload_http_client(); var utils_1 = require_utils13(); @@ -156828,7 +157212,7 @@ var require_artifact_client = __commonJS({ */ uploadArtifact(name, files, rootDirectory, options) { return __awaiter2(this, void 0, void 0, function* () { - core14.info(`Starting artifact upload + core15.info(`Starting artifact upload For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging`); (0, path_and_artifact_name_validation_1.checkArtifactName)(name); const uploadSpecification = (0, upload_specification_1.getUploadSpecification)(name, rootDirectory, files); @@ -156840,24 +157224,24 @@ For more detailed logs during the artifact upload process, enable step-debugging }; const uploadHttpClient = new upload_http_client_1.UploadHttpClient(); if (uploadSpecification.length === 0) { - core14.warning(`No files found that can be uploaded`); + core15.warning(`No files found that can be uploaded`); } else { const response = yield uploadHttpClient.createArtifactInFileContainer(name, options); if (!response.fileContainerResourceUrl) { - core14.debug(response.toString()); + core15.debug(response.toString()); throw new Error("No URL provided by the Artifact Service to upload an artifact to"); } - core14.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); - core14.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`); + core15.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); + core15.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`); const uploadResult = yield uploadHttpClient.uploadArtifactToFileContainer(response.fileContainerResourceUrl, uploadSpecification, options); - core14.info(`File upload process has finished. Finalizing the artifact upload`); + core15.info(`File upload process has finished. Finalizing the artifact upload`); yield uploadHttpClient.patchArtifactSize(uploadResult.totalSize, name); if (uploadResult.failedItems.length > 0) { - core14.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`); + core15.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`); } else { - core14.info(`Artifact has been finalized. All files have been successfully uploaded!`); + core15.info(`Artifact has been finalized. All files have been successfully uploaded!`); } - core14.info(` + core15.info(` The raw size of all the files that were specified for upload is ${uploadResult.totalSize} bytes The size of all the files that were uploaded is ${uploadResult.uploadSize} bytes. This takes into account any gzip compression used to reduce the upload size, time and storage @@ -156891,10 +157275,10 @@ Note: The size of downloaded zips can differ significantly from the reported siz path4 = (0, path_1.resolve)(path4); const downloadSpecification = (0, download_specification_1.getDownloadSpecification)(name, items.value, path4, (options === null || options === void 0 ? void 0 : options.createArtifactFolder) || false); if (downloadSpecification.filesToDownload.length === 0) { - core14.info(`No downloadable files were found for the artifact: ${artifactToDownload.name}`); + core15.info(`No downloadable files were found for the artifact: ${artifactToDownload.name}`); } else { yield (0, utils_1.createDirectoriesForArtifact)(downloadSpecification.directoryStructure); - core14.info("Directory structure has been set up for the artifact"); + core15.info("Directory structure has been set up for the artifact"); yield (0, utils_1.createEmptyFilesForArtifact)(downloadSpecification.emptyFilesToCreate); yield downloadHttpClient.downloadSingleArtifact(downloadSpecification.filesToDownload); } @@ -156910,7 +157294,7 @@ Note: The size of downloaded zips can differ significantly from the reported siz const response = []; const artifacts = yield downloadHttpClient.listArtifacts(); if (artifacts.count === 0) { - core14.info("Unable to find any artifacts for the associated workflow"); + core15.info("Unable to find any artifacts for the associated workflow"); return response; } if (!path4) { @@ -156922,11 +157306,11 @@ Note: The size of downloaded zips can differ significantly from the reported siz while (downloadedArtifacts < artifacts.count) { const currentArtifactToDownload = artifacts.value[downloadedArtifacts]; downloadedArtifacts += 1; - core14.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`); + core15.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`); const items = yield downloadHttpClient.getContainerItems(currentArtifactToDownload.name, currentArtifactToDownload.fileContainerResourceUrl); const downloadSpecification = (0, download_specification_1.getDownloadSpecification)(currentArtifactToDownload.name, items.value, path4, true); if (downloadSpecification.filesToDownload.length === 0) { - core14.info(`No downloadable files were found for any artifact ${currentArtifactToDownload.name}`); + core15.info(`No downloadable files were found for any artifact ${currentArtifactToDownload.name}`); } else { yield (0, utils_1.createDirectoriesForArtifact)(downloadSpecification.directoryStructure); yield (0, utils_1.createEmptyFilesForArtifact)(downloadSpecification.emptyFilesToCreate); @@ -157177,7 +157561,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -157200,10 +157584,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core14.info(err.message); + core15.info(err.message); } const seconds = this.getSleepAmount(); - core14.info(`Waiting ${seconds} seconds before trying again`); + core15.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -157306,7 +157690,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var io6 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs3 = __importStar2(require("fs")); @@ -157335,8 +157719,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path4.join(_getTempDirectory(), crypto2.randomUUID()); yield io6.mkdirP(path4.dirname(dest)); - core14.debug(`Downloading ${url}`); - core14.debug(`Destination ${dest}`); + core15.debug(`Downloading ${url}`); + core15.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -157362,7 +157746,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -157371,7 +157755,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { const err = new HTTPError(response.message.statusCode); - core14.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core15.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream.pipeline); @@ -157380,16 +157764,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs3.createWriteStream(dest)); - core14.debug("download complete"); + core15.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core14.debug("download failed"); + core15.debug("download failed"); try { yield io6.rmRF(dest); } catch (err) { - core14.debug(`Failed to delete '${dest}'. ${err.message}`); + core15.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -157404,7 +157788,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core14.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core15.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -157457,7 +157841,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core14.debug("Checking tar --version"); + core15.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -157467,7 +157851,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core14.debug(versionOutput.trim()); + core15.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -157475,7 +157859,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core14.isDebug() && !flags.includes("v")) { + if (core15.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -157506,7 +157890,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core14.isDebug()) { + if (core15.isDebug()) { args.push("-v"); } const xarPath = yield io6.which("xar", true); @@ -157549,7 +157933,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core14.debug(`Using pwsh at path: ${pwshPath}`); + core15.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -157569,7 +157953,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io6.which("powershell", true); - core14.debug(`Using powershell at path: ${powershellPath}`); + core15.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -157578,7 +157962,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io6.which("unzip", true); const args = [file]; - if (!core14.isDebug()) { + if (!core15.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -157589,8 +157973,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch}`); - core14.debug(`source dir: ${sourceDir}`); + core15.debug(`Caching tool ${tool} ${version} ${arch}`); + core15.debug(`source dir: ${sourceDir}`); if (!fs3.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -157607,14 +157991,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch}`); - core14.debug(`source file: ${sourceFile}`); + core15.debug(`Caching tool ${tool} ${version} ${arch}`); + core15.debug(`source file: ${sourceFile}`); if (!fs3.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch); const destPath = path4.join(destFolder, targetFile); - core14.debug(`destination file ${destPath}`); + core15.debug(`destination file ${destPath}`); yield io6.cp(sourceFile, destPath); _completeToolPath(tool, version, arch); return destFolder; @@ -157637,12 +158021,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path4.join(_getCacheDirectory(), toolName, versionSpec, arch); - core14.debug(`checking cache: ${cachePath}`); + core15.debug(`checking cache: ${cachePath}`); if (fs3.existsSync(cachePath) && fs3.existsSync(`${cachePath}.complete`)) { - core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); toolPath = cachePath; } else { - core14.debug("not found"); + core15.debug("not found"); } } return toolPath; @@ -157671,7 +158055,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -157692,7 +158076,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core14.debug("Invalid json"); + core15.debug("Invalid json"); } } return releases; @@ -157716,7 +158100,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path4.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); - core14.debug(`destination ${folderPath}`); + core15.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io6.rmRF(folderPath); yield io6.rmRF(markerPath); @@ -157728,18 +158112,18 @@ var require_tool_cache = __commonJS({ const folderPath = path4.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); const markerPath = `${folderPath}.complete`; fs3.writeFileSync(markerPath, ""); - core14.debug("finished caching tool"); + core15.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core14.debug(`isExplicit: ${c}`); + core15.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core14.debug(`explicit? ${valid3}`); + core15.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core14.debug(`evaluating ${versions.length} versions`); + core15.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -157755,9 +158139,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core14.debug(`matched: ${version}`); + core15.debug(`matched: ${version}`); } else { - core14.debug("match not found"); + core15.debug("match not found"); } return version; } @@ -158333,7 +158717,7 @@ var require_follow_redirects = __commonJS({ }); // src/start-proxy-action-post.ts -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); // src/actions-util.ts var core4 = __toESM(require_core()); @@ -161095,7 +161479,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } var persistedInputsKey = "persisted_inputs"; var restoreInputs = function() { @@ -161242,6 +161626,7 @@ async function getGitHubVersion() { // src/config-utils.ts var fs = __toESM(require("fs")); var path = __toESM(require("path")); +var core9 = __toESM(require_core()); // src/analyses.ts var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => { @@ -161306,6 +161691,7 @@ var semver3 = __toESM(require_semver2()); // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -161397,6 +161783,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -161427,6 +161818,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -161437,16 +161833,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -161462,15 +161848,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -161531,6 +161933,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -161539,6 +161942,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -161575,17 +161979,17 @@ async function getConfig(tempDir, logger) { var path3 = __toESM(require("path")); var artifact = __toESM(require_artifact2()); var artifactLegacy = __toESM(require_artifact_client2()); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); var import_archiver = __toESM(require_archiver()); // src/analyze.ts var io5 = __toESM(require_io()); // src/autobuild.ts -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); // src/codeql.ts -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -161736,7 +162140,7 @@ var toolcache = __toESM(require_tool_cache()); var semver6 = __toESM(require_semver2()); // src/tools-download.ts -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -162005,10 +162409,10 @@ function getArtifactSuffix(matrix) { for (const matrixKey of Object.keys(matrixObject).sort()) suffix += `-${matrixObject[matrixKey]}`; } else { - core12.warning("User-specified `matrix` input is not an object."); + core13.warning("User-specified `matrix` input is not an object."); } } catch { - core12.warning( + core13.warning( "Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input." ); } @@ -162021,7 +162425,7 @@ async function uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVarian } if (isInTestMode()) { await scanArtifactsForTokens(toUpload, logger); - core12.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true"); + core13.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true"); } const suffix = getArtifactSuffix(getOptionalInput("matrix")); const artifactUploader = await getArtifactUploaderClient(logger, ghVariant); @@ -162037,7 +162441,7 @@ async function uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVarian ); return "upload-successful"; } catch (e) { - core12.warning(`Failed to upload debug artifacts: ${e}`); + core13.warning(`Failed to upload debug artifacts: ${e}`); return "upload-failed"; } } @@ -162060,7 +162464,7 @@ async function runWrapper() { const logger = getActionsLogger(); try { restoreInputs(); - const pid = core13.getState("proxy-process-pid"); + const pid = core14.getState("proxy-process-pid"); if (pid) { process.kill(Number(pid)); } @@ -162068,8 +162472,8 @@ async function runWrapper() { getTemporaryDirectory(), logger ); - if (config?.debugMode || core13.isDebug()) { - const logFilePath = core13.getState("proxy-log-file"); + if (config?.debugMode || core14.isDebug()) { + const logFilePath = core14.getState("proxy-log-file"); logger.info( "Debug mode is on. Uploading proxy log as Actions debugging artifact..." ); diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index ff9f7e54a4..d297079c0a 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable4; + exports2.exportVariable = exportVariable5; exports2.setSecret = setSecret2; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable4(name, val) { + function exportVariable5(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -47343,7 +47343,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -47355,23 +47355,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core12.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core13.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core12.debug(`implicitDescendants '${result.implicitDescendants}'`); + core13.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core12.debug(`matchDirectories '${result.matchDirectories}'`); + core13.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core12.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core13.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core12.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core13.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -48999,7 +48999,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var fs3 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path5 = __importStar2(require("path")); @@ -49052,7 +49052,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core12.debug(`Search path '${searchPath}'`); + core13.debug(`Search path '${searchPath}'`); try { yield __await2(fs3.promises.lstat(searchPath)); } catch (err) { @@ -49127,7 +49127,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core12.debug(`Broken symlink '${item.path}'`); + core13.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -49143,7 +49143,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core12.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core13.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -49246,7 +49246,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles; var crypto2 = __importStar2(require("crypto")); - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var fs3 = __importStar2(require("fs")); var stream = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -49255,7 +49255,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core12.info : core12.debug; + const writeDelegate = verbose ? core13.info : core13.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -50646,7 +50646,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var exec3 = __importStar2(require_exec()); var glob = __importStar2(require_glob()); var io5 = __importStar2(require_io()); @@ -50697,7 +50697,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path5.relative(workspace, file).replace(new RegExp(`\\${path5.sep}`, "g"), "/"); - core12.debug(`Matched: ${relativeFile}`); + core13.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -50725,7 +50725,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core12.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core13.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec3.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -50736,10 +50736,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core12.debug(err.message); + core13.debug(err.message); } versionOutput = versionOutput.trim(); - core12.debug(versionOutput); + core13.debug(versionOutput); return versionOutput; }); } @@ -50747,7 +50747,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver6.clean(versionOutput); - core12.debug(`zstd version: ${version}`); + core13.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -60530,44 +60530,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -60575,63 +60575,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -60640,16 +60640,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -60658,83 +60658,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -60748,190 +60755,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -60941,290 +61157,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + } + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; + } + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function lt(t2, e2, i2) { + return pt(t2, e2, i2); } - function H(t2, e2, n2) { - let i2; + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -61233,172 +61484,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } } - return s2; + return i2; } - function ot(t2) { + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + } + return i2; + } + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -90403,7 +90787,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -90445,7 +90829,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core12.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core13.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -90502,14 +90886,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core12.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core13.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core12.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core13.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -90594,7 +90978,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -90652,9 +91036,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core12.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core13.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core12.debug(`${name} - Error is not retryable`); + core13.debug(`${name} - Error is not retryable`); break; } yield sleep(delay2); @@ -90913,7 +91297,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -90951,7 +91335,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core12.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core13.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -90985,7 +91369,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core12.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core13.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91035,7 +91419,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core12.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core13.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -91046,7 +91430,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core12.debug("Unable to validate download, no Content-Length header"); + core13.debug("Unable to validate download, no Content-Length header"); } }); } @@ -91164,7 +91548,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core12.debug("Unable to determine content length, downloading file with http-client..."); + core13.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -91254,7 +91638,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -91274,9 +91658,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core12.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core12.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core12.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core13.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core13.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core13.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -91312,12 +91696,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core12.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core12.debug(`Download concurrency: ${result.downloadConcurrency}`); - core12.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core12.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core12.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core12.debug(`Lookup only: ${result.lookupOnly}`); + core13.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core13.debug(`Download concurrency: ${result.downloadConcurrency}`); + core13.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core13.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core13.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core13.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -91511,7 +91895,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache4; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs3 = __importStar2(require("fs")); @@ -91529,7 +91913,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url = `${baseUrl}_apis/artifactcache/${resource}`; - core12.debug(`Resource Url: ${url}`); + core13.debug(`Resource Url: ${url}`); return url; } function createAcceptHeader(type2, apiVersion) { @@ -91557,7 +91941,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core12.isDebug()) { + if (core13.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -91570,9 +91954,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core12.setSecret(cacheDownloadUrl); - core12.debug(`Cache Result:`); - core12.debug(JSON.stringify(cacheResult)); + core13.setSecret(cacheDownloadUrl); + core13.debug(`Cache Result:`); + core13.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -91586,10 +91970,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core12.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core13.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core12.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core13.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -91632,7 +92016,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core12.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core13.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -91654,7 +92038,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core12.debug("Awaiting all uploads"); + core13.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -91697,16 +92081,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core12.debug("Upload cache"); + core13.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core12.debug("Commiting cache"); + core13.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core12.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core13.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core12.info("Cache saved successfully"); + core13.info("Cache saved successfully"); } }); } @@ -97189,7 +97573,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache4; exports2.saveCache = saveCache4; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var path5 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -97248,7 +97632,7 @@ var require_cache5 = __commonJS({ function restoreCache4(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core12.debug(`Cache service version: ${cacheServiceVersion}`); + core13.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -97263,8 +97647,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core12.debug("Resolved Keys:"); - core12.debug(JSON.stringify(keys)); + core13.debug("Resolved Keys:"); + core13.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -97282,19 +97666,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core12.info("Lookup only - skipping download"); + core13.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path5.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core12.debug(`Archive Path: ${archivePath}`); + core13.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core12.isDebug()) { + if (core13.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core12.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core13.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core12.info("Cache restored successfully"); + core13.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -97302,16 +97686,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core12.error(`Failed to restore: ${error3.message}`); + core13.error(`Failed to restore: ${error3.message}`); } else { - core12.warning(`Failed to restore: ${error3.message}`); + core13.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core12.debug(`Failed to delete archive: ${error3}`); + core13.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -97322,8 +97706,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core12.debug("Resolved Keys:"); - core12.debug(JSON.stringify(keys)); + core13.debug("Resolved Keys:"); + core13.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -97341,30 +97725,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request3); if (!response.ok) { - core12.debug(`Cache not found for version ${request3.version} of keys: ${keys.join(", ")}`); + core13.debug(`Cache not found for version ${request3.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request3.key !== response.matchedKey; if (isRestoreKeyMatch) { - core12.info(`Cache hit for restore-key: ${response.matchedKey}`); + core13.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core12.info(`Cache hit for: ${response.matchedKey}`); + core13.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core12.info("Lookup only - skipping download"); + core13.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path5.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core12.debug(`Archive path: ${archivePath}`); - core12.debug(`Starting download of archive to: ${archivePath}`); + core13.debug(`Archive path: ${archivePath}`); + core13.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core12.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core12.isDebug()) { + core13.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core13.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core12.info("Cache restored successfully"); + core13.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -97372,9 +97756,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core12.error(`Failed to restore: ${error3.message}`); + core13.error(`Failed to restore: ${error3.message}`); } else { - core12.warning(`Failed to restore: ${error3.message}`); + core13.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -97383,7 +97767,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core12.debug(`Failed to delete archive: ${error3}`); + core13.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -97392,7 +97776,7 @@ var require_cache5 = __commonJS({ function saveCache4(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core12.debug(`Cache service version: ${cacheServiceVersion}`); + core13.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -97410,26 +97794,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core12.debug("Cache Paths:"); - core12.debug(`${JSON.stringify(cachePaths)}`); + core13.debug("Cache Paths:"); + core13.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path5.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core12.debug(`Archive Path: ${archivePath}`); + core13.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core12.isDebug()) { + if (core13.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core12.debug(`File Size: ${archiveFileSize}`); + core13.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core12.debug("Reserving Cache"); + core13.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -97442,26 +97826,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core12.debug(`Saving Cache (ID: ${cacheId})`); + core13.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core12.info(`Failed to save: ${typedError.message}`); + core13.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core12.error(`Failed to save: ${typedError.message}`); + core13.error(`Failed to save: ${typedError.message}`); } else { - core12.warning(`Failed to save: ${typedError.message}`); + core13.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core12.debug(`Failed to delete archive: ${error3}`); + core13.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -97474,23 +97858,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core12.debug("Cache Paths:"); - core12.debug(`${JSON.stringify(cachePaths)}`); + core13.debug("Cache Paths:"); + core13.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path5.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core12.debug(`Archive Path: ${archivePath}`); + core13.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core12.isDebug()) { + if (core13.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core12.debug(`File Size: ${archiveFileSize}`); + core13.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core12.debug("Reserving Cache"); + core13.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request3 = { key, @@ -97501,16 +97885,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request3); if (!response.ok) { if (response.message) { - core12.warning(`Cache reservation failed: ${response.message}`); + core13.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core12.debug(`Failed to reserve cache: ${error3}`); + core13.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core12.debug(`Attempting to upload cache located at: ${archivePath}`); + core13.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -97518,7 +97902,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core12.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core13.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -97531,21 +97915,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core12.info(`Failed to save: ${typedError.message}`); + core13.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core12.warning(typedError.message); + core13.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core12.error(`Failed to save: ${typedError.message}`); + core13.error(`Failed to save: ${typedError.message}`); } else { - core12.warning(`Failed to save: ${typedError.message}`); + core13.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core12.debug(`Failed to delete archive: ${error3}`); + core13.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -97772,7 +98156,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -97795,10 +98179,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core12.info(err.message); + core13.info(err.message); } const seconds = this.getSleepAmount(); - core12.info(`Waiting ${seconds} seconds before trying again`); + core13.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -97901,7 +98285,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core12 = __importStar2(require_core()); + var core13 = __importStar2(require_core()); var io5 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs3 = __importStar2(require("fs")); @@ -97930,8 +98314,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path5.join(_getTempDirectory(), crypto2.randomUUID()); yield io5.mkdirP(path5.dirname(dest)); - core12.debug(`Downloading ${url}`); - core12.debug(`Destination ${dest}`); + core13.debug(`Downloading ${url}`); + core13.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -97957,7 +98341,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core12.debug("set auth"); + core13.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -97966,7 +98350,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core12.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core13.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream.pipeline); @@ -97975,16 +98359,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs3.createWriteStream(dest)); - core12.debug("download complete"); + core13.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core12.debug("download failed"); + core13.debug("download failed"); try { yield io5.rmRF(dest); } catch (err) { - core12.debug(`Failed to delete '${dest}'. ${err.message}`); + core13.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -97999,7 +98383,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core12.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core13.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -98052,7 +98436,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core12.debug("Checking tar --version"); + core13.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -98062,7 +98446,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core12.debug(versionOutput.trim()); + core13.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -98070,7 +98454,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core12.isDebug() && !flags.includes("v")) { + if (core13.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -98101,7 +98485,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core12.isDebug()) { + if (core13.isDebug()) { args.push("-v"); } const xarPath = yield io5.which("xar", true); @@ -98144,7 +98528,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core12.debug(`Using pwsh at path: ${pwshPath}`); + core13.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -98164,7 +98548,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io5.which("powershell", true); - core12.debug(`Using powershell at path: ${powershellPath}`); + core13.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -98173,7 +98557,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io5.which("unzip", true); const args = [file]; - if (!core12.isDebug()) { + if (!core13.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -98184,8 +98568,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver6.clean(version) || version; arch = arch || os2.arch(); - core12.debug(`Caching tool ${tool} ${version} ${arch}`); - core12.debug(`source dir: ${sourceDir}`); + core13.debug(`Caching tool ${tool} ${version} ${arch}`); + core13.debug(`source dir: ${sourceDir}`); if (!fs3.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -98202,14 +98586,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver6.clean(version) || version; arch = arch || os2.arch(); - core12.debug(`Caching tool ${tool} ${version} ${arch}`); - core12.debug(`source file: ${sourceFile}`); + core13.debug(`Caching tool ${tool} ${version} ${arch}`); + core13.debug(`source file: ${sourceFile}`); if (!fs3.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch); const destPath = path5.join(destFolder, targetFile); - core12.debug(`destination file ${destPath}`); + core13.debug(`destination file ${destPath}`); yield io5.cp(sourceFile, destPath); _completeToolPath(tool, version, arch); return destFolder; @@ -98232,12 +98616,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver6.clean(versionSpec) || ""; const cachePath = path5.join(_getCacheDirectory(), toolName, versionSpec, arch); - core12.debug(`checking cache: ${cachePath}`); + core13.debug(`checking cache: ${cachePath}`); if (fs3.existsSync(cachePath) && fs3.existsSync(`${cachePath}.complete`)) { - core12.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + core13.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); toolPath = cachePath; } else { - core12.debug("not found"); + core13.debug("not found"); } } return toolPath; @@ -98266,7 +98650,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core12.debug("set auth"); + core13.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -98287,7 +98671,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core12.debug("Invalid json"); + core13.debug("Invalid json"); } } return releases; @@ -98311,7 +98695,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path5.join(_getCacheDirectory(), tool, semver6.clean(version) || version, arch || ""); - core12.debug(`destination ${folderPath}`); + core13.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io5.rmRF(folderPath); yield io5.rmRF(markerPath); @@ -98323,18 +98707,18 @@ var require_tool_cache = __commonJS({ const folderPath = path5.join(_getCacheDirectory(), tool, semver6.clean(version) || version, arch || ""); const markerPath = `${folderPath}.complete`; fs3.writeFileSync(markerPath, ""); - core12.debug("finished caching tool"); + core13.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver6.clean(versionSpec) || ""; - core12.debug(`isExplicit: ${c}`); + core13.debug(`isExplicit: ${c}`); const valid2 = semver6.valid(c) != null; - core12.debug(`explicit? ${valid2}`); + core13.debug(`explicit? ${valid2}`); return valid2; } function evaluateVersions(versions, versionSpec) { let version = ""; - core12.debug(`evaluating ${versions.length} versions`); + core13.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver6.gt(a, b)) { return 1; @@ -98350,9 +98734,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core12.debug(`matched: ${version}`); + core13.debug(`matched: ${version}`); } else { - core12.debug("match not found"); + core13.debug("match not found"); } return version; } @@ -117460,7 +117844,7 @@ var require_lib3 = __commonJS({ // src/start-proxy-action.ts var import_child_process = require("child_process"); var path4 = __toESM(require("path")); -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); // src/actions-util.ts var core4 = __toESM(require_core()); @@ -120274,7 +120658,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -120521,8 +120905,8 @@ var path = __toESM(require("path")); var semver4 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.24.3"; -var cliVersion = "2.24.3"; +var bundleVersion = "codeql-bundle-v2.25.0"; +var cliVersion = "2.25.0"; // src/overlay/index.ts var actionsCache = __toESM(require_cache5()); @@ -120640,6 +121024,7 @@ function getActionsLogger() { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -120733,6 +121118,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -120763,6 +121153,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -120773,16 +121168,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -120798,15 +121183,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -121179,7 +121580,7 @@ function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) { // src/start-proxy.ts var path2 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolcache = __toESM(require_tool_cache()); // src/artifact-scanner.ts @@ -121331,6 +121732,9 @@ function getAddressString(address) { // src/status-report.ts var os = __toESM(require("os")); +var core10 = __toESM(require_core()); + +// src/config-utils.ts var core9 = __toESM(require_core()); // src/analyses.ts @@ -121378,6 +121782,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -121386,6 +121791,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -121410,12 +121816,12 @@ function getActionsStatus(error3, otherFailureCause) { } function setJobStatusIfUnsuccessful(actionStatus) { if (actionStatus === "user-error") { - core9.exportVariable( + core10.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); } else if (actionStatus === "failure" || actionStatus === "aborted") { - core9.exportVariable( + core10.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_FAILURE" /* FailureStatus */ ); @@ -121434,14 +121840,14 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi let workflowStartedAt = process.env["CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */]; if (workflowStartedAt === void 0) { workflowStartedAt = actionStartedAt.toISOString(); - core9.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); + core10.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); const codeQlCliVersion = getCachedCodeQlVersion(); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { - core9.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); + core10.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); } const isSteadyStateDefaultSetupRun = process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true"; const statusReport = { @@ -121524,9 +121930,9 @@ var INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the API endpo async function sendStatusReport(statusReport) { setJobStatusIfUnsuccessful(statusReport.status); const statusReportJSON = JSON.stringify(statusReport); - core9.debug(`Sending status report: ${statusReportJSON}`); + core10.debug(`Sending status report: ${statusReportJSON}`); if (isInTestMode()) { - core9.debug("In test mode. Status reports are not uploaded."); + core10.debug("In test mode. Status reports are not uploaded."); return; } const nwo = getRepositoryNwo(); @@ -121546,28 +121952,28 @@ async function sendStatusReport(statusReport) { switch (httpError.status) { case 403: if (getWorkflowEventName() === "push" && process.env["GITHUB_ACTOR"] === "dependabot[bot]") { - core9.warning( + core10.warning( `Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading CodeQL results requires write access. To use CodeQL with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. See ${"https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push" /* SCANNING_ON_PUSH */} for more information on how to configure these events.` ); } else { - core9.warning( + core10.warning( `This run of the CodeQL Action does not have permission to access the CodeQL Action API endpoints. This could be because the Action is running on a pull request from a fork. If not, please ensure the workflow has at least the 'security-events: read' permission. Details: ${httpError.message}` ); } return; case 404: - core9.warning(httpError.message); + core10.warning(httpError.message); return; case 422: if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { - core9.debug(INCOMPATIBLE_MSG); + core10.debug(INCOMPATIBLE_MSG); } else { - core9.debug(OUT_OF_DATE_MSG); + core10.debug(OUT_OF_DATE_MSG); } return; } } - core9.warning( + core10.warning( `An unexpected error occurred when sending a status report: ${getErrorMessage( e )}` @@ -121642,7 +122048,7 @@ function getSafeErrorMessage(error3) { } async function sendFailedStatusReport(logger, startedAt, language, unwrappedError) { const error3 = wrapError(unwrappedError); - core10.setFailed(`start-proxy action failed: ${error3.message}`); + core11.setFailed(`start-proxy action failed: ${error3.message}`); const statusReportMessage = getSafeErrorMessage(error3); const errorStatusReportBase = await createStatusReportBase( "start-proxy" /* StartProxy */, @@ -121748,14 +122154,14 @@ function getAuthConfig(config) { }; } else if (isToken(config)) { if (isDefined2(config.token)) { - core10.setSecret(config.token); + core11.setSecret(config.token); } return { username: config.username, token: config.token }; } else { let username = void 0; let password = void 0; if ("password" in config && isString(config.password)) { - core10.setSecret(config.password); + core11.setSecret(config.password); password = config.password; } if ("username" in config && isString(config.username)) { @@ -122248,7 +122654,7 @@ async function run(startedAt) { persistInputs(); const tempDir = getTemporaryDirectory(); const proxyLogFilePath = path4.resolve(tempDir, "proxy.log"); - core11.saveState("proxy-log-file", proxyLogFilePath); + core12.saveState("proxy-log-file", proxyLogFilePath); const repositoryNwo = getRepositoryNwo(); const gitHubVersion = await getGitHubVersion(); features = initFeatures( @@ -122277,7 +122683,7 @@ async function run(startedAt) { `Credentials loaded for the following registries: ${credentials.map((c) => credentialToStr(c)).join("\n")}` ); - if (core11.isDebug() || isInTestMode()) { + if (core12.isDebug() || isInTestMode()) { try { await checkProxyEnvironment(logger, language); } catch (err) { @@ -122317,7 +122723,7 @@ async function runWrapper() { try { await run(startedAt); } catch (error3) { - core11.setFailed(`start-proxy action failed: ${getErrorMessage(error3)}`); + core12.setFailed(`start-proxy action failed: ${getErrorMessage(error3)}`); await sendUnhandledErrorStatusReport( "start-proxy" /* StartProxy */, startedAt, @@ -122343,7 +122749,7 @@ async function startProxy(binPath, config, logFilePath, logger) { ); subprocess.unref(); if (subprocess.pid) { - core11.saveState("proxy-process-pid", `${subprocess.pid}`); + core12.saveState("proxy-process-pid", `${subprocess.pid}`); } subprocess.on("error", (error3) => { subprocessError = error3; @@ -122362,14 +122768,14 @@ async function startProxy(binPath, config, logFilePath, logger) { throw subprocessError; } logger.info(`Proxy started on ${host}:${port}`); - core11.setOutput("proxy_host", host); - core11.setOutput("proxy_port", port.toString()); - core11.setOutput("proxy_ca_certificate", config.ca.cert); + core12.setOutput("proxy_host", host); + core12.setOutput("proxy_port", port.toString()); + core12.setOutput("proxy_ca_certificate", config.ca.cert); const registry_urls = config.all_credentials.filter((credential) => credential.url !== void 0).map((credential) => ({ type: credential.type, url: credential.url })); - core11.setOutput("proxy_urls", JSON.stringify(registry_urls)); + core12.setOutput("proxy_urls", JSON.stringify(registry_urls)); return { host, port, cert: config.ca.cert, registries: registry_urls }; } void runWrapper(); diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 27870330d1..5fffee480c 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable6; + exports2.exportVariable = exportVariable7; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable6(name, val) { + function exportVariable7(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -48640,7 +48640,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -48652,23 +48652,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core13.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core14.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core13.debug(`implicitDescendants '${result.implicitDescendants}'`); + core14.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core13.debug(`matchDirectories '${result.matchDirectories}'`); + core14.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core13.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core14.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core13.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core14.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -50296,7 +50296,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var fs13 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path12 = __importStar2(require("path")); @@ -50349,7 +50349,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core13.debug(`Search path '${searchPath}'`); + core14.debug(`Search path '${searchPath}'`); try { yield __await2(fs13.promises.lstat(searchPath)); } catch (err) { @@ -50424,7 +50424,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core13.debug(`Broken symlink '${item.path}'`); + core14.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -50440,7 +50440,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core13.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core14.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -50543,7 +50543,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles; var crypto2 = __importStar2(require("crypto")); - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var fs13 = __importStar2(require("fs")); var stream2 = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -50552,7 +50552,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core13.info : core13.debug; + const writeDelegate = verbose ? core14.info : core14.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -51943,7 +51943,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var exec = __importStar2(require_exec()); var glob = __importStar2(require_glob()); var io6 = __importStar2(require_io()); @@ -51994,7 +51994,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path12.relative(workspace, file).replace(new RegExp(`\\${path12.sep}`, "g"), "/"); - core13.debug(`Matched: ${relativeFile}`); + core14.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -52022,7 +52022,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core13.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core14.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -52033,10 +52033,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core13.debug(err.message); + core14.debug(err.message); } versionOutput = versionOutput.trim(); - core13.debug(versionOutput); + core14.debug(versionOutput); return versionOutput; }); } @@ -52044,7 +52044,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core13.debug(`zstd version: ${version}`); + core14.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -61827,44 +61827,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -61872,63 +61872,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -61937,16 +61937,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -61955,83 +61955,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -62045,190 +62052,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -62238,290 +62454,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; + } + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; + } + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; + } + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function lt(t2, e2, i2) { + return pt(t2, e2, i2); } - function H(t2, e2, n2) { - let i2; + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -62530,172 +62781,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } + } + return i2; + } + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return s2; + return i2; } - function ot(t2) { + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -91700,7 +92084,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -91742,7 +92126,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core13.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core14.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91799,14 +92183,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core13.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core14.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core13.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core14.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -91891,7 +92275,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -91949,9 +92333,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core13.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core14.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core13.debug(`${name} - Error is not retryable`); + core14.debug(`${name} - Error is not retryable`); break; } yield sleep(delay2); @@ -92210,7 +92594,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -92248,7 +92632,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core13.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core14.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -92282,7 +92666,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core13.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core14.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -92332,7 +92716,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core13.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core14.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -92343,7 +92727,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core13.debug("Unable to validate download, no Content-Length header"); + core14.debug("Unable to validate download, no Content-Length header"); } }); } @@ -92461,7 +92845,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core13.debug("Unable to determine content length, downloading file with http-client..."); + core14.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -92551,7 +92935,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -92571,9 +92955,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core13.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core13.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core13.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core14.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core14.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -92609,12 +92993,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core13.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core13.debug(`Download concurrency: ${result.downloadConcurrency}`); - core13.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core13.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core13.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core13.debug(`Lookup only: ${result.lookupOnly}`); + core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core14.debug(`Download concurrency: ${result.downloadConcurrency}`); + core14.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core14.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core14.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core14.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -92808,7 +93192,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache4; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs13 = __importStar2(require("fs")); @@ -92826,7 +93210,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url2 = `${baseUrl}_apis/artifactcache/${resource}`; - core13.debug(`Resource Url: ${url2}`); + core14.debug(`Resource Url: ${url2}`); return url2; } function createAcceptHeader(type2, apiVersion) { @@ -92854,7 +93238,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core13.isDebug()) { + if (core14.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -92867,9 +93251,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core13.setSecret(cacheDownloadUrl); - core13.debug(`Cache Result:`); - core13.debug(JSON.stringify(cacheResult)); + core14.setSecret(cacheDownloadUrl); + core14.debug(`Cache Result:`); + core14.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -92883,10 +93267,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core13.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core14.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core13.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core14.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -92929,7 +93313,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core13.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core14.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -92951,7 +93335,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core13.debug("Awaiting all uploads"); + core14.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -92994,16 +93378,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core13.debug("Upload cache"); + core14.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core13.debug("Commiting cache"); + core14.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core14.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core13.info("Cache saved successfully"); + core14.info("Cache saved successfully"); } }); } @@ -98486,7 +98870,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache4; exports2.saveCache = saveCache4; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var path12 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -98545,7 +98929,7 @@ var require_cache5 = __commonJS({ function restoreCache4(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core13.debug(`Cache service version: ${cacheServiceVersion}`); + core14.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -98560,8 +98944,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core13.debug("Resolved Keys:"); - core13.debug(JSON.stringify(keys)); + core14.debug("Resolved Keys:"); + core14.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98579,19 +98963,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core13.info("Lookup only - skipping download"); + core14.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path12.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core13.debug(`Archive Path: ${archivePath}`); + core14.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core13.isDebug()) { + if (core14.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core13.info("Cache restored successfully"); + core14.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -98599,16 +98983,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core13.error(`Failed to restore: ${error3.message}`); + core14.error(`Failed to restore: ${error3.message}`); } else { - core13.warning(`Failed to restore: ${error3.message}`); + core14.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core13.debug(`Failed to delete archive: ${error3}`); + core14.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98619,8 +99003,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core13.debug("Resolved Keys:"); - core13.debug(JSON.stringify(keys)); + core14.debug("Resolved Keys:"); + core14.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -98638,30 +99022,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core13.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core14.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core13.info(`Cache hit for restore-key: ${response.matchedKey}`); + core14.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core13.info(`Cache hit for: ${response.matchedKey}`); + core14.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core13.info("Lookup only - skipping download"); + core14.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path12.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core13.debug(`Archive path: ${archivePath}`); - core13.debug(`Starting download of archive to: ${archivePath}`); + core14.debug(`Archive path: ${archivePath}`); + core14.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core13.isDebug()) { + core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core14.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core13.info("Cache restored successfully"); + core14.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -98669,9 +99053,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core13.error(`Failed to restore: ${error3.message}`); + core14.error(`Failed to restore: ${error3.message}`); } else { - core13.warning(`Failed to restore: ${error3.message}`); + core14.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -98680,7 +99064,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core13.debug(`Failed to delete archive: ${error3}`); + core14.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -98689,7 +99073,7 @@ var require_cache5 = __commonJS({ function saveCache4(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core13.debug(`Cache service version: ${cacheServiceVersion}`); + core14.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -98707,26 +99091,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core13.debug("Cache Paths:"); - core13.debug(`${JSON.stringify(cachePaths)}`); + core14.debug("Cache Paths:"); + core14.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path12.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core13.debug(`Archive Path: ${archivePath}`); + core14.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core13.isDebug()) { + if (core14.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.debug(`File Size: ${archiveFileSize}`); + core14.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core13.debug("Reserving Cache"); + core14.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -98739,26 +99123,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core13.debug(`Saving Cache (ID: ${cacheId})`); + core14.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core13.info(`Failed to save: ${typedError.message}`); + core14.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core13.error(`Failed to save: ${typedError.message}`); + core14.error(`Failed to save: ${typedError.message}`); } else { - core13.warning(`Failed to save: ${typedError.message}`); + core14.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core13.debug(`Failed to delete archive: ${error3}`); + core14.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -98771,23 +99155,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core13.debug("Cache Paths:"); - core13.debug(`${JSON.stringify(cachePaths)}`); + core14.debug("Cache Paths:"); + core14.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path12.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core13.debug(`Archive Path: ${archivePath}`); + core14.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core13.isDebug()) { + if (core14.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core13.debug(`File Size: ${archiveFileSize}`); + core14.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core13.debug("Reserving Cache"); + core14.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -98798,16 +99182,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core13.warning(`Cache reservation failed: ${response.message}`); + core14.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core13.debug(`Failed to reserve cache: ${error3}`); + core14.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core13.debug(`Attempting to upload cache located at: ${archivePath}`); + core14.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -98815,7 +99199,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core13.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core14.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -98828,21 +99212,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core13.info(`Failed to save: ${typedError.message}`); + core14.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core13.warning(typedError.message); + core14.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core13.error(`Failed to save: ${typedError.message}`); + core14.error(`Failed to save: ${typedError.message}`); } else { - core13.warning(`Failed to save: ${typedError.message}`); + core14.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core13.debug(`Failed to delete archive: ${error3}`); + core14.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99069,7 +99453,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99092,10 +99476,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core13.info(err.message); + core14.info(err.message); } const seconds = this.getSleepAmount(); - core13.info(`Waiting ${seconds} seconds before trying again`); + core14.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99198,7 +99582,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core13 = __importStar2(require_core()); + var core14 = __importStar2(require_core()); var io6 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs13 = __importStar2(require("fs")); @@ -99227,8 +99611,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path12.join(_getTempDirectory(), crypto2.randomUUID()); yield io6.mkdirP(path12.dirname(dest)); - core13.debug(`Downloading ${url2}`); - core13.debug(`Destination ${dest}`); + core14.debug(`Downloading ${url2}`); + core14.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99254,7 +99638,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core13.debug("set auth"); + core14.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99263,7 +99647,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url2, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core13.debug(`Failed to download from "${url2}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core14.debug(`Failed to download from "${url2}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream2.pipeline); @@ -99272,16 +99656,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs13.createWriteStream(dest)); - core13.debug("download complete"); + core14.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core13.debug("download failed"); + core14.debug("download failed"); try { yield io6.rmRF(dest); } catch (err) { - core13.debug(`Failed to delete '${dest}'. ${err.message}`); + core14.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99296,7 +99680,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core13.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core14.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core13.debug("Checking tar --version"); + core14.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99359,7 +99743,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core13.debug(versionOutput.trim()); + core14.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99367,7 +99751,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core13.isDebug() && !flags.includes("v")) { + if (core14.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99398,7 +99782,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core13.isDebug()) { + if (core14.isDebug()) { args.push("-v"); } const xarPath = yield io6.which("xar", true); @@ -99441,7 +99825,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core13.debug(`Using pwsh at path: ${pwshPath}`); + core14.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99461,7 +99845,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io6.which("powershell", true); - core13.debug(`Using powershell at path: ${powershellPath}`); + core14.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99470,7 +99854,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io6.which("unzip", true); const args = [file]; - if (!core13.isDebug()) { + if (!core14.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99481,8 +99865,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os2.arch(); - core13.debug(`Caching tool ${tool} ${version} ${arch2}`); - core13.debug(`source dir: ${sourceDir}`); + core14.debug(`Caching tool ${tool} ${version} ${arch2}`); + core14.debug(`source dir: ${sourceDir}`); if (!fs13.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99499,14 +99883,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os2.arch(); - core13.debug(`Caching tool ${tool} ${version} ${arch2}`); - core13.debug(`source file: ${sourceFile}`); + core14.debug(`Caching tool ${tool} ${version} ${arch2}`); + core14.debug(`source file: ${sourceFile}`); if (!fs13.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch2); const destPath = path12.join(destFolder, targetFile); - core13.debug(`destination file ${destPath}`); + core14.debug(`destination file ${destPath}`); yield io6.cp(sourceFile, destPath); _completeToolPath(tool, version, arch2); return destFolder; @@ -99529,12 +99913,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path12.join(_getCacheDirectory(), toolName, versionSpec, arch2); - core13.debug(`checking cache: ${cachePath}`); + core14.debug(`checking cache: ${cachePath}`); if (fs13.existsSync(cachePath) && fs13.existsSync(`${cachePath}.complete`)) { - core13.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); + core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); toolPath = cachePath; } else { - core13.debug("not found"); + core14.debug("not found"); } } return toolPath; @@ -99563,7 +99947,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core13.debug("set auth"); + core14.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99584,7 +99968,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core13.debug("Invalid json"); + core14.debug("Invalid json"); } } return releases; @@ -99608,7 +99992,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch2) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path12.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); - core13.debug(`destination ${folderPath}`); + core14.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io6.rmRF(folderPath); yield io6.rmRF(markerPath); @@ -99620,18 +100004,18 @@ var require_tool_cache = __commonJS({ const folderPath = path12.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); const markerPath = `${folderPath}.complete`; fs13.writeFileSync(markerPath, ""); - core13.debug("finished caching tool"); + core14.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core13.debug(`isExplicit: ${c}`); + core14.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core13.debug(`explicit? ${valid3}`); + core14.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core13.debug(`evaluating ${versions.length} versions`); + core14.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -99647,9 +100031,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core13.debug(`matched: ${version}`); + core14.debug(`matched: ${version}`); } else { - core13.debug("match not found"); + core14.debug("match not found"); } return version; } @@ -103124,6 +103508,7 @@ var require_sarif_schema_2_1_0 = __commonJS({ var upload_lib_exports = {}; __export(upload_lib_exports, { buildPayload: () => buildPayload, + filterAlertsByDiffRange: () => filterAlertsByDiffRange, findSarifFilesInDir: () => findSarifFilesInDir, getGroupedSarifFilePaths: () => getGroupedSarifFilePaths, populateRunAutomationDetails: () => populateRunAutomationDetails, @@ -103146,7 +103531,7 @@ var fs12 = __toESM(require("fs")); var path11 = __toESM(require("path")); var url = __toESM(require("url")); var import_zlib = __toESM(require("zlib")); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); var jsonschema2 = __toESM(require_lib2()); // src/actions-util.ts @@ -106017,7 +106402,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -106466,7 +106851,7 @@ function wrapApiConfigurationError(e) { // src/codeql.ts var fs9 = __toESM(require("fs")); var path9 = __toESM(require("path")); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -106714,6 +107099,7 @@ function wrapCliConfigurationError(cliError) { // src/config-utils.ts var fs5 = __toESM(require("fs")); var path6 = __toESM(require("path")); +var core9 = __toESM(require_core()); // src/caching-utils.ts var core6 = __toESM(require_core()); @@ -106835,8 +107221,8 @@ var path5 = __toESM(require("path")); var semver5 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.24.3"; -var cliVersion = "2.24.3"; +var bundleVersion = "codeql-bundle-v2.25.0"; +var cliVersion = "2.25.0"; // src/overlay/index.ts var fs3 = __toESM(require("fs")); @@ -107044,6 +107430,7 @@ async function isAnalyzingDefaultBranch() { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -107192,6 +107579,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -107222,6 +107614,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -107232,16 +107629,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -107257,15 +107644,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -107344,6 +107747,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -107352,6 +107756,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -107626,7 +108031,7 @@ var fs7 = __toESM(require("fs")); var os = __toESM(require("os")); var path7 = __toESM(require("path")); var import_perf_hooks = require("perf_hooks"); -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -107680,10 +108085,10 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat }; } } catch (e) { - core9.warning( + core10.warning( `Failed to download and extract CodeQL bundle using streaming with error: ${getErrorMessage(e)}` ); - core9.warning(`Falling back to downloading the bundle before extracting.`); + core10.warning(`Falling back to downloading the bundle before extracting.`); await cleanUpPath(dest, "CodeQL bundle", logger); } const toolsDownloadStart = import_perf_hooks.performance.now(); @@ -108365,7 +108770,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, checkVersion) { try { const { @@ -108709,17 +109113,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -108868,12 +109268,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core10.warning( + core11.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core10.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -110101,7 +110501,7 @@ async function addFingerprints(sarifLog, sourceRoot, logger) { } // src/init.ts -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); var toolrunner4 = __toESM(require_toolrunner()); var github2 = __toESM(require_github()); var io5 = __toESM(require_io()); @@ -110245,7 +110645,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo logger.warning( `Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}` ); - core12.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); + core13.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); } return combineSarifFiles(sarifFiles, logger); } @@ -110344,13 +110744,13 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) { if (httpError !== void 0) { switch (httpError.status) { case 403: - core12.warning(httpError.message || GENERIC_403_MSG); + core13.warning(httpError.message || GENERIC_403_MSG); break; case 404: - core12.warning(httpError.message || GENERIC_404_MSG); + core13.warning(httpError.message || GENERIC_404_MSG); break; default: - core12.warning(httpError.message); + core13.warning(httpError.message); break; } } @@ -110784,7 +111184,7 @@ function validateUniqueCategory(sarifLog, sentinelPrefix) { `Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per tool/category. The easiest fix is to specify a unique value for the \`category\` input. If .runs[].automationDetails.id is specified in the sarif file, that will take precedence over your configured \`category\`. Category: (${id ? id : "none"}) Tool: (${tool ? tool : "none"})` ); } - core12.exportVariable(sentinelEnvVar, sentinelEnvVar); + core13.exportVariable(sentinelEnvVar, sentinelEnvVar); } } function sanitize(str2) { @@ -110798,7 +111198,6 @@ function filterAlertsByDiffRange(logger, sarifLog) { if (sarifLog.runs === void 0) { return sarifLog; } - const checkoutPath = getRequiredInput("checkout_path"); for (const run of sarifLog.runs) { if (run.results) { run.results = run.results.filter((result) => { @@ -110812,9 +111211,8 @@ function filterAlertsByDiffRange(logger, sarifLog) { if (!locationUri || locationStartLine === void 0) { return false; } - const locationPath = path11.join(checkoutPath, locationUri).replaceAll(path11.sep, "/"); return diffRanges.some( - (range) => range.path === locationPath && (range.startLine <= locationStartLine && range.endLine >= locationStartLine || range.startLine === 0 && range.endLine === 0) + (range) => range.path === locationUri && (range.startLine <= locationStartLine && range.endLine >= locationStartLine || range.startLine === 0 && range.endLine === 0) ); }); }); @@ -110825,6 +111223,7 @@ function filterAlertsByDiffRange(logger, sarifLog) { // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { buildPayload, + filterAlertsByDiffRange, findSarifFilesInDir, getGroupedSarifFilePaths, populateRunAutomationDetails, diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index 1566f48968..1cce8e7d13 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable6; + exports2.exportVariable = exportVariable7; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable6(name, val) { + function exportVariable7(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -53633,14 +53633,14 @@ var require_retention = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getExpiration = void 0; var generated_1 = require_generated(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getExpiration(retentionDays) { if (!retentionDays) { return void 0; } const maxRetentionDays = getRetentionDays(); if (maxRetentionDays && maxRetentionDays < retentionDays) { - core14.warning(`Retention days cannot be greater than the maximum allowed retention set within the repository. Using ${maxRetentionDays} instead.`); + core15.warning(`Retention days cannot be greater than the maximum allowed retention set within the repository. Using ${maxRetentionDays} instead.`); retentionDays = maxRetentionDays; } const expirationDate = /* @__PURE__ */ new Date(); @@ -53978,7 +53978,7 @@ var require_util17 = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.maskSecretUrls = exports2.maskSigUrl = exports2.getBackendIdsFromToken = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var config_1 = require_config(); var jwt_decode_1 = __importDefault2(require_jwt_decode_cjs()); var core_1 = require_core(); @@ -54005,8 +54005,8 @@ var require_util17 = __commonJS({ workflowRunBackendId: scopeParts[1], workflowJobRunBackendId: scopeParts[2] }; - core14.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); - core14.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); + core15.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`); + core15.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`); return ids; } throw InvalidJwtError; @@ -64040,44 +64040,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -64085,63 +64085,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -64150,16 +64150,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -64168,83 +64168,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -64258,190 +64265,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _2(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _2(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _2(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _2(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_2(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _2(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _2(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _2(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _2 = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _2), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -64451,290 +64667,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; + } + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; } - function H(t2, e2, n2) { - let i2; + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; + } + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; + } + function lt(t2, e2, i2) { + return pt(t2, e2, i2); + } + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -64743,172 +64994,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } + } + return i2; + } + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; } - return s2; + return i2; } - function ot(t2) { + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -93820,7 +94204,7 @@ var require_blob_upload = __commonJS({ exports2.uploadZipToBlobStorage = void 0; var storage_blob_1 = require_commonjs17(); var config_1 = require_config(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var crypto2 = __importStar2(require("crypto")); var stream = __importStar2(require("stream")); var errors_1 = require_errors3(); @@ -93846,9 +94230,9 @@ var require_blob_upload = __commonJS({ const bufferSize = (0, config_1.getUploadChunkSize)(); const blobClient = new storage_blob_1.BlobClient(authenticatedUploadURL); const blockBlobClient = blobClient.getBlockBlobClient(); - core14.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`); + core15.debug(`Uploading artifact zip to blob storage with maxConcurrency: ${maxConcurrency}, bufferSize: ${bufferSize}`); const uploadCallback = (progress) => { - core14.info(`Uploaded bytes ${progress.loadedBytes}`); + core15.info(`Uploaded bytes ${progress.loadedBytes}`); uploadByteCount = progress.loadedBytes; lastProgressTime = Date.now(); }; @@ -93862,7 +94246,7 @@ var require_blob_upload = __commonJS({ const hashStream = crypto2.createHash("sha256"); zipUploadStream.pipe(uploadStream); zipUploadStream.pipe(hashStream).setEncoding("hex"); - core14.info("Beginning upload of artifact content to blob storage"); + core15.info("Beginning upload of artifact content to blob storage"); try { yield Promise.race([ blockBlobClient.uploadStream(uploadStream, bufferSize, maxConcurrency, options), @@ -93876,12 +94260,12 @@ var require_blob_upload = __commonJS({ } finally { abortController.abort(); } - core14.info("Finished uploading artifact content to blob storage!"); + core15.info("Finished uploading artifact content to blob storage!"); hashStream.end(); sha256Hash = hashStream.read(); - core14.info(`SHA256 digest of uploaded artifact zip is ${sha256Hash}`); + core15.info(`SHA256 digest of uploaded artifact zip is ${sha256Hash}`); if (uploadByteCount === 0) { - core14.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`); + core15.warning(`No data was uploaded to blob storage. Reported upload byte count is 0.`); } return { uploadSize: uploadByteCount, @@ -119277,7 +119661,7 @@ var require_zip2 = __commonJS({ var stream = __importStar2(require("stream")); var promises_1 = require("fs/promises"); var archiver2 = __importStar2(require_archiver()); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var config_1 = require_config(); exports2.DEFAULT_COMPRESSION_LEVEL = 6; var ZipUploadStream = class extends stream.Transform { @@ -119294,7 +119678,7 @@ var require_zip2 = __commonJS({ exports2.ZipUploadStream = ZipUploadStream; function createZipUploadStream(uploadSpecification_1) { return __awaiter2(this, arguments, void 0, function* (uploadSpecification, compressionLevel = exports2.DEFAULT_COMPRESSION_LEVEL) { - core14.debug(`Creating Artifact archive with compressionLevel: ${compressionLevel}`); + core15.debug(`Creating Artifact archive with compressionLevel: ${compressionLevel}`); const zip = archiver2.create("zip", { highWaterMark: (0, config_1.getUploadChunkSize)(), zlib: { level: compressionLevel } @@ -119318,8 +119702,8 @@ var require_zip2 = __commonJS({ } const bufferSize = (0, config_1.getUploadChunkSize)(); const zipUploadStream = new ZipUploadStream(bufferSize); - core14.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`); - core14.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`); + core15.debug(`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`); + core15.debug(`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`); zip.pipe(zipUploadStream); zip.finalize(); return zipUploadStream; @@ -119327,24 +119711,24 @@ var require_zip2 = __commonJS({ } exports2.createZipUploadStream = createZipUploadStream; var zipErrorCallback = (error3) => { - core14.error("An error has occurred while creating the zip file for upload"); - core14.info(error3); + core15.error("An error has occurred while creating the zip file for upload"); + core15.info(error3); throw new Error("An error has occurred during zip creation for the artifact"); }; var zipWarningCallback = (error3) => { if (error3.code === "ENOENT") { - core14.warning("ENOENT warning during artifact zip creation. No such file or directory"); - core14.info(error3); + core15.warning("ENOENT warning during artifact zip creation. No such file or directory"); + core15.info(error3); } else { - core14.warning(`A non-blocking warning has occurred during artifact zip creation: ${error3.code}`); - core14.info(error3); + core15.warning(`A non-blocking warning has occurred during artifact zip creation: ${error3.code}`); + core15.info(error3); } }; var zipFinishCallback = () => { - core14.debug("Zip stream for upload has finished."); + core15.debug("Zip stream for upload has finished."); }; var zipEndCallback = () => { - core14.debug("Zip stream for upload has ended."); + core15.debug("Zip stream for upload has ended."); }; } }); @@ -119409,7 +119793,7 @@ var require_upload_artifact = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.uploadArtifact = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var retention_1 = require_retention(); var path_and_artifact_name_validation_1 = require_path_and_artifact_name_validation(); var artifact_twirp_client_1 = require_artifact_twirp_client2(); @@ -119456,13 +119840,13 @@ var require_upload_artifact = __commonJS({ value: `sha256:${uploadResult.sha256Hash}` }); } - core14.info(`Finalizing artifact upload`); + core15.info(`Finalizing artifact upload`); const finalizeArtifactResp = yield artifactClient.FinalizeArtifact(finalizeArtifactReq); if (!finalizeArtifactResp.ok) { throw new errors_1.InvalidResponseError("FinalizeArtifact: response from backend was not ok"); } const artifactId = BigInt(finalizeArtifactResp.artifactId); - core14.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`); + core15.info(`Artifact ${name}.zip successfully finalized. Artifact ID ${artifactId}`); return { size: uploadResult.uploadSize, digest: uploadResult.sha256Hash, @@ -142943,7 +143327,7 @@ var require_download_artifact = __commonJS({ var crypto2 = __importStar2(require("crypto")); var stream = __importStar2(require("stream")); var github2 = __importStar2(require_github2()); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var httpClient = __importStar2(require_lib()); var unzip_stream_1 = __importDefault2(require_unzip()); var user_agent_1 = require_user_agent(); @@ -142979,7 +143363,7 @@ var require_download_artifact = __commonJS({ return yield streamExtractExternal(url, directory); } catch (error3) { retryCount++; - core14.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); + core15.debug(`Failed to download artifact after ${retryCount} retries due to ${error3.message}. Retrying in 5 seconds...`); yield new Promise((resolve2) => setTimeout(resolve2, 5e3)); } } @@ -143009,7 +143393,7 @@ var require_download_artifact = __commonJS({ extractStream.on("data", () => { timer.refresh(); }).on("error", (error3) => { - core14.debug(`response.message: Artifact download failed: ${error3.message}`); + core15.debug(`response.message: Artifact download failed: ${error3.message}`); clearTimeout(timer); reject(error3); }).pipe(unzip_stream_1.default.Extract({ path: directory })).on("close", () => { @@ -143017,7 +143401,7 @@ var require_download_artifact = __commonJS({ if (hashStream) { hashStream.end(); sha256Digest = hashStream.read(); - core14.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); + core15.info(`SHA256 digest of downloaded artifact is ${sha256Digest}`); } resolve2({ sha256Digest: `sha256:${sha256Digest}` }); }).on("error", (error3) => { @@ -143032,7 +143416,7 @@ var require_download_artifact = __commonJS({ const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path); const api = github2.getOctokit(token); let digestMismatch = false; - core14.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`); + core15.info(`Downloading artifact '${artifactId}' from '${repositoryOwner}/${repositoryName}'`); const { headers, status } = yield api.rest.actions.downloadArtifact({ owner: repositoryOwner, repo: repositoryName, @@ -143049,16 +143433,16 @@ var require_download_artifact = __commonJS({ if (!location) { throw new Error(`Unable to redirect to artifact download url`); } - core14.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`); + core15.info(`Redirecting to blob download url: ${scrubQueryParameters(location)}`); try { - core14.info(`Starting download of artifact to: ${downloadPath}`); + core15.info(`Starting download of artifact to: ${downloadPath}`); const extractResponse = yield streamExtract(location, downloadPath); - core14.info(`Artifact download completed successfully.`); + core15.info(`Artifact download completed successfully.`); if (options === null || options === void 0 ? void 0 : options.expectedHash) { if ((options === null || options === void 0 ? void 0 : options.expectedHash) !== extractResponse.sha256Digest) { digestMismatch = true; - core14.debug(`Computed digest: ${extractResponse.sha256Digest}`); - core14.debug(`Expected digest: ${options.expectedHash}`); + core15.debug(`Computed digest: ${extractResponse.sha256Digest}`); + core15.debug(`Expected digest: ${options.expectedHash}`); } } } catch (error3) { @@ -143085,7 +143469,7 @@ var require_download_artifact = __commonJS({ Are you trying to download from a different run? Try specifying a github-token with \`actions:read\` scope.`); } if (artifacts.length > 1) { - core14.warning("Multiple artifacts found, defaulting to first."); + core15.warning("Multiple artifacts found, defaulting to first."); } const signedReq = { workflowRunBackendId: artifacts[0].workflowRunBackendId, @@ -143093,16 +143477,16 @@ Are you trying to download from a different run? Try specifying a github-token w name: artifacts[0].name }; const { signedUrl } = yield artifactClient.GetSignedArtifactURL(signedReq); - core14.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`); + core15.info(`Redirecting to blob download url: ${scrubQueryParameters(signedUrl)}`); try { - core14.info(`Starting download of artifact to: ${downloadPath}`); + core15.info(`Starting download of artifact to: ${downloadPath}`); const extractResponse = yield streamExtract(signedUrl, downloadPath); - core14.info(`Artifact download completed successfully.`); + core15.info(`Artifact download completed successfully.`); if (options === null || options === void 0 ? void 0 : options.expectedHash) { if ((options === null || options === void 0 ? void 0 : options.expectedHash) !== extractResponse.sha256Digest) { digestMismatch = true; - core14.debug(`Computed digest: ${extractResponse.sha256Digest}`); - core14.debug(`Expected digest: ${options.expectedHash}`); + core15.debug(`Computed digest: ${extractResponse.sha256Digest}`); + core15.debug(`Expected digest: ${options.expectedHash}`); } } } catch (error3) { @@ -143115,10 +143499,10 @@ Are you trying to download from a different run? Try specifying a github-token w function resolveOrCreateDirectory() { return __awaiter2(this, arguments, void 0, function* (downloadPath = (0, config_1.getGitHubWorkspaceDir)()) { if (!(yield exists(downloadPath))) { - core14.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`); + core15.debug(`Artifact destination folder does not exist, creating: ${downloadPath}`); yield promises_1.default.mkdir(downloadPath, { recursive: true }); } else { - core14.debug(`Artifact destination folder already exists: ${downloadPath}`); + core15.debug(`Artifact destination folder already exists: ${downloadPath}`); } return downloadPath; }); @@ -143159,7 +143543,7 @@ var require_retry_options = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getRetryOptions = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var defaultMaxRetryNumber = 5; var defaultExemptStatusCodes = [400, 401, 403, 404, 422]; function getRetryOptions(defaultOptions, retries = defaultMaxRetryNumber, exemptStatusCodes = defaultExemptStatusCodes) { @@ -143174,7 +143558,7 @@ var require_retry_options = __commonJS({ retryOptions.doNotRetry = exemptStatusCodes; } const requestOptions = Object.assign(Object.assign({}, defaultOptions.request), { retries }); - core14.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : "octokit default: [400, 401, 403, 404, 422]"})`); + core15.debug(`GitHub client configured with: (retries: ${requestOptions.retries}, retry-exempt-status-code: ${(_a = retryOptions.doNotRetry) !== null && _a !== void 0 ? _a : "octokit default: [400, 401, 403, 404, 422]"})`); return [retryOptions, requestOptions]; } exports2.getRetryOptions = getRetryOptions; @@ -143331,7 +143715,7 @@ var require_get_artifact = __commonJS({ exports2.getArtifactInternal = exports2.getArtifactPublic = void 0; var github_1 = require_github2(); var plugin_retry_1 = require_dist_node12(); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var utils_1 = require_utils11(); var retry_options_1 = require_retry_options(); var plugin_request_log_1 = require_dist_node11(); @@ -143369,7 +143753,7 @@ var require_get_artifact = __commonJS({ let artifact2 = getArtifactResp.data.artifacts[0]; if (getArtifactResp.data.artifacts.length > 1) { artifact2 = getArtifactResp.data.artifacts.sort((a, b) => b.id - a.id)[0]; - core14.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.id})`); + core15.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.id})`); } return { artifact: { @@ -143402,7 +143786,7 @@ var require_get_artifact = __commonJS({ let artifact2 = res.artifacts[0]; if (res.artifacts.length > 1) { artifact2 = res.artifacts.sort((a, b) => Number(b.databaseId) - Number(a.databaseId))[0]; - core14.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.databaseId})`); + core15.debug(`More than one artifact found for a single name, returning newest (id: ${artifact2.databaseId})`); } return { artifact: { @@ -146510,7 +146894,7 @@ var require_core3 = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable6(name, val) { + function exportVariable7(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -146519,7 +146903,7 @@ var require_core3 = __commonJS({ } (0, command_1.issueCommand)("set-env", { name }, convertedVal); } - exports2.exportVariable = exportVariable6; + exports2.exportVariable = exportVariable7; function setSecret(secret) { (0, command_1.issueCommand)("add-mask", {}, secret); } @@ -148140,7 +148524,7 @@ var require_requestUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.retryHttpClientRequest = exports2.retry = void 0; var utils_1 = require_utils13(); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var config_variables_1 = require_config_variables(); function retry2(name, operation, customErrorMessages, maxAttempts) { return __awaiter2(this, void 0, void 0, function* () { @@ -148167,13 +148551,13 @@ var require_requestUtils = __commonJS({ errorMessage = error3.message; } if (!isRetryable) { - core14.info(`${name} - Error is not retryable`); + core15.info(`${name} - Error is not retryable`); if (response) { (0, utils_1.displayHttpDiagnostics)(response); } break; } - core14.info(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core15.info(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); yield (0, utils_1.sleep)((0, utils_1.getExponentialRetryTimeInMilliseconds)(attempt)); attempt++; } @@ -148257,7 +148641,7 @@ var require_upload_http_client = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadHttpClient = void 0; var fs3 = __importStar2(require("fs")); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var tmp = __importStar2(require_tmp_promise()); var stream = __importStar2(require("stream")); var utils_1 = require_utils13(); @@ -148322,7 +148706,7 @@ var require_upload_http_client = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const FILE_CONCURRENCY = (0, config_variables_1.getUploadFileConcurrency)(); const MAX_CHUNK_SIZE = (0, config_variables_1.getUploadChunkSize)(); - core14.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`); + core15.debug(`File Concurrency: ${FILE_CONCURRENCY}, and Chunk Size: ${MAX_CHUNK_SIZE}`); const parameters = []; let continueOnError = true; if (options) { @@ -148359,15 +148743,15 @@ var require_upload_http_client = __commonJS({ } const startTime = perf_hooks_1.performance.now(); const uploadFileResult = yield this.uploadFileAsync(index, currentFileParameters); - if (core14.isDebug()) { - core14.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`); + if (core15.isDebug()) { + core15.debug(`File: ${++completedFiles}/${filesToUpload.length}. ${currentFileParameters.file} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish upload`); } uploadFileSize += uploadFileResult.successfulUploadSize; totalFileSize += uploadFileResult.totalSize; if (uploadFileResult.isSuccess === false) { failedItemsToReport.push(currentFileParameters.file); if (!continueOnError) { - core14.error(`aborting artifact upload`); + core15.error(`aborting artifact upload`); abortPendingFileUploads = true; } } @@ -148376,7 +148760,7 @@ var require_upload_http_client = __commonJS({ }))); this.statusReporter.stop(); this.uploadHttpManager.disposeAndReplaceAllClients(); - core14.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`); + core15.info(`Total size of all the files uploaded is ${uploadFileSize} bytes`); return { uploadSize: uploadFileSize, totalSize: totalFileSize, @@ -148402,16 +148786,16 @@ var require_upload_http_client = __commonJS({ let uploadFileSize = 0; let isGzip = true; if (!isFIFO && totalFileSize < 65536) { - core14.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`); + core15.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`); const buffer = yield (0, upload_gzip_1.createGZipFileInBuffer)(parameters.file); let openUploadStream; if (totalFileSize < buffer.byteLength) { - core14.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); + core15.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); openUploadStream = () => fs3.createReadStream(parameters.file); isGzip = false; uploadFileSize = totalFileSize; } else { - core14.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`); + core15.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`); openUploadStream = () => { const passThrough = new stream.PassThrough(); passThrough.end(buffer); @@ -148423,7 +148807,7 @@ var require_upload_http_client = __commonJS({ if (!result) { isUploadSuccessful = false; failedChunkSizes += uploadFileSize; - core14.warning(`Aborting upload for ${parameters.file} due to failure`); + core15.warning(`Aborting upload for ${parameters.file} due to failure`); } return { isSuccess: isUploadSuccessful, @@ -148432,16 +148816,16 @@ var require_upload_http_client = __commonJS({ }; } else { const tempFile = yield tmp.file(); - core14.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`); + core15.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`); uploadFileSize = yield (0, upload_gzip_1.createGZipFileOnDisk)(parameters.file, tempFile.path); let uploadFilePath = tempFile.path; if (!isFIFO && totalFileSize < uploadFileSize) { - core14.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); + core15.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`); uploadFileSize = totalFileSize; uploadFilePath = parameters.file; isGzip = false; } else { - core14.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`); + core15.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`); } let abortFileUpload = false; while (offset < uploadFileSize) { @@ -148461,7 +148845,7 @@ var require_upload_http_client = __commonJS({ if (!result) { isUploadSuccessful = false; failedChunkSizes += chunkSize; - core14.warning(`Aborting upload for ${parameters.file} due to failure`); + core15.warning(`Aborting upload for ${parameters.file} due to failure`); abortFileUpload = true; } else { if (uploadFileSize > 8388608) { @@ -148469,7 +148853,7 @@ var require_upload_http_client = __commonJS({ } } } - core14.debug(`deleting temporary gzip file ${tempFile.path}`); + core15.debug(`deleting temporary gzip file ${tempFile.path}`); yield tempFile.cleanup(); return { isSuccess: isUploadSuccessful, @@ -148508,7 +148892,7 @@ var require_upload_http_client = __commonJS({ if (response) { (0, utils_1.displayHttpDiagnostics)(response); } - core14.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`); + core15.info(`Retry limit has been reached for chunk at offset ${start} to ${resourceUrl}`); return true; } return false; @@ -148516,14 +148900,14 @@ var require_upload_http_client = __commonJS({ const backOff = (retryAfterValue) => __awaiter2(this, void 0, void 0, function* () { this.uploadHttpManager.disposeAndReplaceClient(httpClientIndex); if (retryAfterValue) { - core14.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`); + core15.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the upload`); yield (0, utils_1.sleep)(retryAfterValue); } else { const backoffTime = (0, utils_1.getExponentialRetryTimeInMilliseconds)(retryCount); - core14.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`); + core15.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the upload at offset ${start}`); yield (0, utils_1.sleep)(backoffTime); } - core14.info(`Finished backoff for retry #${retryCount}, continuing with upload`); + core15.info(`Finished backoff for retry #${retryCount}, continuing with upload`); return; }); while (retryCount <= retryLimit) { @@ -148531,7 +148915,7 @@ var require_upload_http_client = __commonJS({ try { response = yield uploadChunkRequest(); } catch (error3) { - core14.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`); + core15.info(`An error has been caught http-client index ${httpClientIndex}, retrying the upload`); console.log(error3); if (incrementAndCheckRetryLimit()) { return false; @@ -148543,13 +148927,13 @@ var require_upload_http_client = __commonJS({ if ((0, utils_1.isSuccessStatusCode)(response.message.statusCode)) { return true; } else if ((0, utils_1.isRetryableStatusCode)(response.message.statusCode)) { - core14.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`); + core15.info(`A ${response.message.statusCode} status code has been received, will attempt to retry the upload`); if (incrementAndCheckRetryLimit(response)) { return false; } (0, utils_1.isThrottledStatusCode)(response.message.statusCode) ? yield backOff((0, utils_1.tryGetRetryAfterValueTimeInMilliseconds)(response.message.headers)) : yield backOff(); } else { - core14.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`); + core15.error(`Unexpected response. Unable to upload chunk to ${resourceUrl}`); (0, utils_1.displayHttpDiagnostics)(response); return false; } @@ -148567,7 +148951,7 @@ var require_upload_http_client = __commonJS({ resourceUrl.searchParams.append("artifactName", artifactName); const parameters = { Size: size }; const data = JSON.stringify(parameters, null, 2); - core14.debug(`URL is ${resourceUrl.toString()}`); + core15.debug(`URL is ${resourceUrl.toString()}`); const client = this.uploadHttpManager.getClient(0); const headers = (0, utils_1.getUploadHeaders)("application/json", false); const customErrorMessages = /* @__PURE__ */ new Map([ @@ -148580,7 +148964,7 @@ var require_upload_http_client = __commonJS({ return client.patch(resourceUrl.toString(), data, headers); }), customErrorMessages); yield response.readBody(); - core14.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`); + core15.debug(`Artifact ${artifactName} has been successfully uploaded, total size in bytes: ${size}`); }); } }; @@ -148649,7 +149033,7 @@ var require_download_http_client = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DownloadHttpClient = void 0; var fs3 = __importStar2(require("fs")); - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var zlib = __importStar2(require("zlib")); var utils_1 = require_utils13(); var url_1 = require("url"); @@ -148703,11 +149087,11 @@ var require_download_http_client = __commonJS({ downloadSingleArtifact(downloadItems) { return __awaiter2(this, void 0, void 0, function* () { const DOWNLOAD_CONCURRENCY = (0, config_variables_1.getDownloadFileConcurrency)(); - core14.debug(`Download file concurrency is set to ${DOWNLOAD_CONCURRENCY}`); + core15.debug(`Download file concurrency is set to ${DOWNLOAD_CONCURRENCY}`); const parallelDownloads = [...new Array(DOWNLOAD_CONCURRENCY).keys()]; let currentFile = 0; let downloadedFiles = 0; - core14.info(`Total number of files that will be downloaded: ${downloadItems.length}`); + core15.info(`Total number of files that will be downloaded: ${downloadItems.length}`); this.statusReporter.setTotalNumberOfFilesToProcess(downloadItems.length); this.statusReporter.start(); yield Promise.all(parallelDownloads.map((index) => __awaiter2(this, void 0, void 0, function* () { @@ -148716,8 +149100,8 @@ var require_download_http_client = __commonJS({ currentFile += 1; const startTime = perf_hooks_1.performance.now(); yield this.downloadIndividualFile(index, currentFileToDownload.sourceLocation, currentFileToDownload.targetPath); - if (core14.isDebug()) { - core14.debug(`File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish downloading`); + if (core15.isDebug()) { + core15.debug(`File: ${++downloadedFiles}/${downloadItems.length}. ${currentFileToDownload.targetPath} took ${(perf_hooks_1.performance.now() - startTime).toFixed(3)} milliseconds to finish downloading`); } this.statusReporter.incrementProcessedCount(); } @@ -148755,19 +149139,19 @@ var require_download_http_client = __commonJS({ } else { this.downloadHttpManager.disposeAndReplaceClient(httpClientIndex); if (retryAfterValue) { - core14.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the download`); + core15.info(`Backoff due to too many requests, retry #${retryCount}. Waiting for ${retryAfterValue} milliseconds before continuing the download`); yield (0, utils_1.sleep)(retryAfterValue); } else { const backoffTime = (0, utils_1.getExponentialRetryTimeInMilliseconds)(retryCount); - core14.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the download`); + core15.info(`Exponential backoff for retry #${retryCount}. Waiting for ${backoffTime} milliseconds before continuing the download`); yield (0, utils_1.sleep)(backoffTime); } - core14.info(`Finished backoff for retry #${retryCount}, continuing with download`); + core15.info(`Finished backoff for retry #${retryCount}, continuing with download`); } }); const isAllBytesReceived = (expected, received) => { if (!expected || !received || process.env["ACTIONS_ARTIFACT_SKIP_DOWNLOAD_VALIDATION"]) { - core14.info("Skipping download validation."); + core15.info("Skipping download validation."); return true; } return parseInt(expected) === received; @@ -148788,7 +149172,7 @@ var require_download_http_client = __commonJS({ try { response = yield makeDownloadRequest(); } catch (error3) { - core14.info("An error occurred while attempting to download a file"); + core15.info("An error occurred while attempting to download a file"); console.log(error3); yield backOff(); continue; @@ -148808,7 +149192,7 @@ var require_download_http_client = __commonJS({ } } if (forceRetry || (0, utils_1.isRetryableStatusCode)(response.message.statusCode)) { - core14.info(`A ${response.message.statusCode} response code has been received while attempting to download an artifact`); + core15.info(`A ${response.message.statusCode} response code has been received while attempting to download an artifact`); resetDestinationStream(downloadPath); (0, utils_1.isThrottledStatusCode)(response.message.statusCode) ? yield backOff((0, utils_1.tryGetRetryAfterValueTimeInMilliseconds)(response.message.headers)) : yield backOff(); } else { @@ -148830,29 +149214,29 @@ var require_download_http_client = __commonJS({ if (isGzip) { const gunzip = zlib.createGunzip(); response.message.on("error", (error3) => { - core14.info(`An error occurred while attempting to read the response stream`); + core15.info(`An error occurred while attempting to read the response stream`); gunzip.close(); destinationStream.close(); reject(error3); }).pipe(gunzip).on("error", (error3) => { - core14.info(`An error occurred while attempting to decompress the response stream`); + core15.info(`An error occurred while attempting to decompress the response stream`); destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { resolve2(); }).on("error", (error3) => { - core14.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); + core15.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); }); } else { response.message.on("error", (error3) => { - core14.info(`An error occurred while attempting to read the response stream`); + core15.info(`An error occurred while attempting to read the response stream`); destinationStream.close(); reject(error3); }).pipe(destinationStream).on("close", () => { resolve2(); }).on("error", (error3) => { - core14.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); + core15.info(`An error occurred while writing a downloaded file to ${destinationStream.path}`); reject(error3); }); } @@ -148991,7 +149375,7 @@ var require_artifact_client = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultArtifactClient = void 0; - var core14 = __importStar2(require_core3()); + var core15 = __importStar2(require_core3()); var upload_specification_1 = require_upload_specification(); var upload_http_client_1 = require_upload_http_client(); var utils_1 = require_utils13(); @@ -149012,7 +149396,7 @@ var require_artifact_client = __commonJS({ */ uploadArtifact(name, files, rootDirectory, options) { return __awaiter2(this, void 0, void 0, function* () { - core14.info(`Starting artifact upload + core15.info(`Starting artifact upload For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging`); (0, path_and_artifact_name_validation_1.checkArtifactName)(name); const uploadSpecification = (0, upload_specification_1.getUploadSpecification)(name, rootDirectory, files); @@ -149024,24 +149408,24 @@ For more detailed logs during the artifact upload process, enable step-debugging }; const uploadHttpClient = new upload_http_client_1.UploadHttpClient(); if (uploadSpecification.length === 0) { - core14.warning(`No files found that can be uploaded`); + core15.warning(`No files found that can be uploaded`); } else { const response = yield uploadHttpClient.createArtifactInFileContainer(name, options); if (!response.fileContainerResourceUrl) { - core14.debug(response.toString()); + core15.debug(response.toString()); throw new Error("No URL provided by the Artifact Service to upload an artifact to"); } - core14.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); - core14.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`); + core15.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`); + core15.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`); const uploadResult = yield uploadHttpClient.uploadArtifactToFileContainer(response.fileContainerResourceUrl, uploadSpecification, options); - core14.info(`File upload process has finished. Finalizing the artifact upload`); + core15.info(`File upload process has finished. Finalizing the artifact upload`); yield uploadHttpClient.patchArtifactSize(uploadResult.totalSize, name); if (uploadResult.failedItems.length > 0) { - core14.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`); + core15.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`); } else { - core14.info(`Artifact has been finalized. All files have been successfully uploaded!`); + core15.info(`Artifact has been finalized. All files have been successfully uploaded!`); } - core14.info(` + core15.info(` The raw size of all the files that were specified for upload is ${uploadResult.totalSize} bytes The size of all the files that were uploaded is ${uploadResult.uploadSize} bytes. This takes into account any gzip compression used to reduce the upload size, time and storage @@ -149075,10 +149459,10 @@ Note: The size of downloaded zips can differ significantly from the reported siz path3 = (0, path_1.resolve)(path3); const downloadSpecification = (0, download_specification_1.getDownloadSpecification)(name, items.value, path3, (options === null || options === void 0 ? void 0 : options.createArtifactFolder) || false); if (downloadSpecification.filesToDownload.length === 0) { - core14.info(`No downloadable files were found for the artifact: ${artifactToDownload.name}`); + core15.info(`No downloadable files were found for the artifact: ${artifactToDownload.name}`); } else { yield (0, utils_1.createDirectoriesForArtifact)(downloadSpecification.directoryStructure); - core14.info("Directory structure has been set up for the artifact"); + core15.info("Directory structure has been set up for the artifact"); yield (0, utils_1.createEmptyFilesForArtifact)(downloadSpecification.emptyFilesToCreate); yield downloadHttpClient.downloadSingleArtifact(downloadSpecification.filesToDownload); } @@ -149094,7 +149478,7 @@ Note: The size of downloaded zips can differ significantly from the reported siz const response = []; const artifacts = yield downloadHttpClient.listArtifacts(); if (artifacts.count === 0) { - core14.info("Unable to find any artifacts for the associated workflow"); + core15.info("Unable to find any artifacts for the associated workflow"); return response; } if (!path3) { @@ -149106,11 +149490,11 @@ Note: The size of downloaded zips can differ significantly from the reported siz while (downloadedArtifacts < artifacts.count) { const currentArtifactToDownload = artifacts.value[downloadedArtifacts]; downloadedArtifacts += 1; - core14.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`); + core15.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`); const items = yield downloadHttpClient.getContainerItems(currentArtifactToDownload.name, currentArtifactToDownload.fileContainerResourceUrl); const downloadSpecification = (0, download_specification_1.getDownloadSpecification)(currentArtifactToDownload.name, items.value, path3, true); if (downloadSpecification.filesToDownload.length === 0) { - core14.info(`No downloadable files were found for any artifact ${currentArtifactToDownload.name}`); + core15.info(`No downloadable files were found for any artifact ${currentArtifactToDownload.name}`); } else { yield (0, utils_1.createDirectoriesForArtifact)(downloadSpecification.directoryStructure); yield (0, utils_1.createEmptyFilesForArtifact)(downloadSpecification.emptyFilesToCreate); @@ -150483,7 +150867,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -150495,23 +150879,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core14.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core15.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core14.debug(`implicitDescendants '${result.implicitDescendants}'`); + core15.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core14.debug(`matchDirectories '${result.matchDirectories}'`); + core15.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core14.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core15.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core14.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core15.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -152084,7 +152468,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs3 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path3 = __importStar2(require("path")); @@ -152137,7 +152521,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core14.debug(`Search path '${searchPath}'`); + core15.debug(`Search path '${searchPath}'`); try { yield __await2(fs3.promises.lstat(searchPath)); } catch (err) { @@ -152212,7 +152596,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core14.debug(`Broken symlink '${item.path}'`); + core15.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -152228,7 +152612,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core14.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core15.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -152331,7 +152715,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles2; var crypto2 = __importStar2(require("crypto")); - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var fs3 = __importStar2(require("fs")); var stream = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -152340,7 +152724,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core14.info : core14.debug; + const writeDelegate = verbose ? core15.info : core15.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -153731,7 +154115,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var exec3 = __importStar2(require_exec()); var glob2 = __importStar2(require_glob2()); var io6 = __importStar2(require_io()); @@ -153782,7 +154166,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path3.relative(workspace, file).replace(new RegExp(`\\${path3.sep}`, "g"), "/"); - core14.debug(`Matched: ${relativeFile}`); + core15.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -153810,7 +154194,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core14.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core15.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec3.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -153821,10 +154205,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core14.debug(err.message); + core15.debug(err.message); } versionOutput = versionOutput.trim(); - core14.debug(versionOutput); + core15.debug(versionOutput); return versionOutput; }); } @@ -153832,7 +154216,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core14.debug(`zstd version: ${version}`); + core15.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -154034,7 +154418,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var storage_blob_1 = require_commonjs17(); var errors_1 = require_errors6(); var UploadProgress = class { @@ -154076,7 +154460,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core15.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -154133,14 +154517,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core14.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core15.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core14.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core15.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -154225,7 +154609,7 @@ var require_requestUtils2 = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants24(); function isSuccessStatusCode(statusCode) { @@ -154283,9 +154667,9 @@ var require_requestUtils2 = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core14.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core15.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core14.debug(`${name} - Error is not retryable`); + core15.debug(`${name} - Error is not retryable`); break; } yield sleep(delay); @@ -154544,7 +154928,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs17(); var buffer = __importStar2(require("buffer")); @@ -154582,7 +154966,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core14.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core15.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -154616,7 +155000,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core14.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core15.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -154666,7 +155050,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core14.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core15.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -154677,7 +155061,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core14.debug("Unable to validate download, no Content-Length header"); + core15.debug("Unable to validate download, no Content-Length header"); } }); } @@ -154795,7 +155179,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core14.debug("Unable to determine content length, downloading file with http-client..."); + core15.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -154885,7 +155269,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -154905,9 +155289,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core14.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core15.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -154943,12 +155327,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core14.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core14.debug(`Download concurrency: ${result.downloadConcurrency}`); - core14.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core14.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core14.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core14.debug(`Lookup only: ${result.lookupOnly}`); + core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core15.debug(`Download concurrency: ${result.downloadConcurrency}`); + core15.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core15.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core15.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core15.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -155142,7 +155526,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache5; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs3 = __importStar2(require("fs")); @@ -155160,7 +155544,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url = `${baseUrl}_apis/artifactcache/${resource}`; - core14.debug(`Resource Url: ${url}`); + core15.debug(`Resource Url: ${url}`); return url; } function createAcceptHeader(type2, apiVersion) { @@ -155188,7 +155572,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core14.isDebug()) { + if (core15.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -155201,9 +155585,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core14.setSecret(cacheDownloadUrl); - core14.debug(`Cache Result:`); - core14.debug(JSON.stringify(cacheResult)); + core15.setSecret(cacheDownloadUrl); + core15.debug(`Cache Result:`); + core15.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -155217,10 +155601,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core14.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core15.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core14.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core15.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -155263,7 +155647,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core14.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core15.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -155285,7 +155669,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core14.debug("Awaiting all uploads"); + core15.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -155328,16 +155712,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core14.debug("Upload cache"); + core15.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core14.debug("Commiting cache"); + core15.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core15.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core14.info("Cache saved successfully"); + core15.info("Cache saved successfully"); } }); } @@ -156594,7 +156978,7 @@ var require_cache6 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache5; exports2.saveCache = saveCache5; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var path3 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -156653,7 +157037,7 @@ var require_cache6 = __commonJS({ function restoreCache5(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -156668,8 +157052,8 @@ var require_cache6 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -156687,19 +157071,19 @@ var require_cache6 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path3.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -156707,16 +157091,16 @@ var require_cache6 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -156727,8 +157111,8 @@ var require_cache6 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core14.debug("Resolved Keys:"); - core14.debug(JSON.stringify(keys)); + core15.debug("Resolved Keys:"); + core15.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -156746,30 +157130,30 @@ var require_cache6 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core14.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core15.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core14.info(`Cache hit for restore-key: ${response.matchedKey}`); + core15.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core14.info(`Cache hit for: ${response.matchedKey}`); + core15.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core14.info("Lookup only - skipping download"); + core15.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path3.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive path: ${archivePath}`); - core14.debug(`Starting download of archive to: ${archivePath}`); + core15.debug(`Archive path: ${archivePath}`); + core15.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core14.isDebug()) { + core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core14.info("Cache restored successfully"); + core15.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -156777,9 +157161,9 @@ var require_cache6 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to restore: ${error3.message}`); + core15.error(`Failed to restore: ${error3.message}`); } else { - core14.warning(`Failed to restore: ${error3.message}`); + core15.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -156788,7 +157172,7 @@ var require_cache6 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -156797,7 +157181,7 @@ var require_cache6 = __commonJS({ function saveCache5(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core14.debug(`Cache service version: ${cacheServiceVersion}`); + core15.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -156815,26 +157199,26 @@ var require_cache6 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path3.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -156847,26 +157231,26 @@ var require_cache6 = __commonJS({ } else { throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core14.debug(`Saving Cache (ID: ${cacheId})`); + core15.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -156879,23 +157263,23 @@ var require_cache6 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core14.debug("Cache Paths:"); - core14.debug(`${JSON.stringify(cachePaths)}`); + core15.debug("Cache Paths:"); + core15.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path3.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core14.debug(`Archive Path: ${archivePath}`); + core15.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core14.isDebug()) { + if (core15.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core14.debug(`File Size: ${archiveFileSize}`); + core15.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core14.debug("Reserving Cache"); + core15.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -156906,16 +157290,16 @@ var require_cache6 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core14.warning(`Cache reservation failed: ${response.message}`); + core15.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core14.debug(`Failed to reserve cache: ${error3}`); + core15.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError2(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core14.debug(`Attempting to upload cache located at: ${archivePath}`); + core15.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -156923,7 +157307,7 @@ var require_cache6 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core14.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core15.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -156936,21 +157320,21 @@ var require_cache6 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError2.name) { - core14.info(`Failed to save: ${typedError.message}`); + core15.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core14.warning(typedError.message); + core15.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core14.error(`Failed to save: ${typedError.message}`); + core15.error(`Failed to save: ${typedError.message}`); } else { - core14.warning(`Failed to save: ${typedError.message}`); + core15.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core14.debug(`Failed to delete archive: ${error3}`); + core15.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -157177,7 +157561,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -157200,10 +157584,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core14.info(err.message); + core15.info(err.message); } const seconds = this.getSleepAmount(); - core14.info(`Waiting ${seconds} seconds before trying again`); + core15.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -157306,7 +157690,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core14 = __importStar2(require_core()); + var core15 = __importStar2(require_core()); var io6 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs3 = __importStar2(require("fs")); @@ -157335,8 +157719,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path3.join(_getTempDirectory(), crypto2.randomUUID()); yield io6.mkdirP(path3.dirname(dest)); - core14.debug(`Downloading ${url}`); - core14.debug(`Destination ${dest}`); + core15.debug(`Downloading ${url}`); + core15.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -157362,7 +157746,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -157371,7 +157755,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { const err = new HTTPError(response.message.statusCode); - core14.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core15.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream.pipeline); @@ -157380,16 +157764,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs3.createWriteStream(dest)); - core14.debug("download complete"); + core15.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core14.debug("download failed"); + core15.debug("download failed"); try { yield io6.rmRF(dest); } catch (err) { - core14.debug(`Failed to delete '${dest}'. ${err.message}`); + core15.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -157404,7 +157788,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core14.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core15.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -157457,7 +157841,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core14.debug("Checking tar --version"); + core15.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -157467,7 +157851,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core14.debug(versionOutput.trim()); + core15.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -157475,7 +157859,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core14.isDebug() && !flags.includes("v")) { + if (core15.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -157506,7 +157890,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core14.isDebug()) { + if (core15.isDebug()) { args.push("-v"); } const xarPath = yield io6.which("xar", true); @@ -157549,7 +157933,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core14.debug(`Using pwsh at path: ${pwshPath}`); + core15.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -157569,7 +157953,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io6.which("powershell", true); - core14.debug(`Using powershell at path: ${powershellPath}`); + core15.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -157578,7 +157962,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io6.which("unzip", true); const args = [file]; - if (!core14.isDebug()) { + if (!core15.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -157589,8 +157973,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch}`); - core14.debug(`source dir: ${sourceDir}`); + core15.debug(`Caching tool ${tool} ${version} ${arch}`); + core15.debug(`source dir: ${sourceDir}`); if (!fs3.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -157607,14 +157991,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch = arch || os2.arch(); - core14.debug(`Caching tool ${tool} ${version} ${arch}`); - core14.debug(`source file: ${sourceFile}`); + core15.debug(`Caching tool ${tool} ${version} ${arch}`); + core15.debug(`source file: ${sourceFile}`); if (!fs3.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch); const destPath = path3.join(destFolder, targetFile); - core14.debug(`destination file ${destPath}`); + core15.debug(`destination file ${destPath}`); yield io6.cp(sourceFile, destPath); _completeToolPath(tool, version, arch); return destFolder; @@ -157637,12 +158021,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path3.join(_getCacheDirectory(), toolName, versionSpec, arch); - core14.debug(`checking cache: ${cachePath}`); + core15.debug(`checking cache: ${cachePath}`); if (fs3.existsSync(cachePath) && fs3.existsSync(`${cachePath}.complete`)) { - core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); toolPath = cachePath; } else { - core14.debug("not found"); + core15.debug("not found"); } } return toolPath; @@ -157671,7 +158055,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core14.debug("set auth"); + core15.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -157692,7 +158076,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core14.debug("Invalid json"); + core15.debug("Invalid json"); } } return releases; @@ -157716,7 +158100,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path3.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); - core14.debug(`destination ${folderPath}`); + core15.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io6.rmRF(folderPath); yield io6.rmRF(markerPath); @@ -157728,18 +158112,18 @@ var require_tool_cache = __commonJS({ const folderPath = path3.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch || ""); const markerPath = `${folderPath}.complete`; fs3.writeFileSync(markerPath, ""); - core14.debug("finished caching tool"); + core15.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core14.debug(`isExplicit: ${c}`); + core15.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core14.debug(`explicit? ${valid3}`); + core15.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core14.debug(`evaluating ${versions.length} versions`); + core15.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -157755,9 +158139,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core14.debug(`matched: ${version}`); + core15.debug(`matched: ${version}`); } else { - core14.debug("match not found"); + core15.debug("match not found"); } return version; } @@ -158333,7 +158717,7 @@ var require_follow_redirects = __commonJS({ }); // src/upload-sarif-action-post.ts -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); // src/actions-util.ts var core4 = __toESM(require_core()); @@ -161095,7 +161479,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } var persistedInputsKey = "persisted_inputs"; var restoreInputs = function() { @@ -161244,7 +161628,7 @@ var fs2 = __toESM(require("fs")); var path2 = __toESM(require("path")); var artifact = __toESM(require_artifact2()); var artifactLegacy = __toESM(require_artifact_client2()); -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); var import_archiver = __toESM(require_archiver()); // src/analyze.ts @@ -161260,10 +161644,10 @@ var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => { var supportedAnalysisKinds = new Set(Object.values(AnalysisKind)); // src/autobuild.ts -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); // src/codeql.ts -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -161402,6 +161786,9 @@ var cliErrorsConfig = { } }; +// src/config-utils.ts +var core9 = __toESM(require_core()); + // src/caching-utils.ts var core6 = __toESM(require_core()); @@ -161464,6 +161851,7 @@ var semver3 = __toESM(require_semver2()); // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -161559,6 +161947,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -161589,6 +161982,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -161599,16 +161997,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -161624,15 +162012,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -161693,6 +162097,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -161701,6 +162106,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -161721,7 +162127,7 @@ var toolcache = __toESM(require_tool_cache()); var semver6 = __toESM(require_semver2()); // src/tools-download.ts -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -162027,10 +162433,10 @@ function getArtifactSuffix(matrix) { for (const matrixKey of Object.keys(matrixObject).sort()) suffix += `-${matrixObject[matrixKey]}`; } else { - core12.warning("User-specified `matrix` input is not an object."); + core13.warning("User-specified `matrix` input is not an object."); } } catch { - core12.warning( + core13.warning( "Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input." ); } @@ -162040,7 +162446,7 @@ function getArtifactSuffix(matrix) { async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghVariant, codeQlVersion) { const uploadSupported = isSafeArtifactUpload(codeQlVersion); if (!uploadSupported) { - core12.info( + core13.info( `Skipping debug artifact upload because the current CLI does not support safe upload. Please upgrade to CLI v${SafeArtifactUploadVersion} or later.` ); return "upload-not-supported"; @@ -162053,7 +162459,7 @@ async function uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVarian } if (isInTestMode()) { await scanArtifactsForTokens(toUpload, logger); - core12.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true"); + core13.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true"); } const suffix = getArtifactSuffix(getOptionalInput("matrix")); const artifactUploader = await getArtifactUploaderClient(logger, ghVariant); @@ -162069,7 +162475,7 @@ async function uploadArtifacts(logger, toUpload, rootDir, artifactName, ghVarian ); return "upload-successful"; } catch (e) { - core12.warning(`Failed to upload debug artifacts: ${e}`); + core13.warning(`Failed to upload debug artifacts: ${e}`); return "upload-failed"; } } @@ -162096,7 +162502,7 @@ async function runWrapper() { checkGitHubVersionInRange(gitHubVersion, logger); if (process.env["CODEQL_ACTION_INIT_HAS_RUN" /* INIT_ACTION_HAS_RUN */] !== "true") { if (gitHubVersion.type === void 0) { - core13.warning( + core14.warning( `Did not upload debug artifacts because cannot determine the GitHub variant running.` ); return; @@ -162113,7 +162519,7 @@ async function runWrapper() { ); } } catch (error3) { - core13.setFailed( + core14.setFailed( `upload-sarif post-action step failed: ${getErrorMessage(error3)}` ); } diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 76f845388f..77f740fe73 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -21321,7 +21321,7 @@ var require_core = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.platform = exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = exports2.markdownSummary = exports2.summary = exports2.ExitCode = void 0; - exports2.exportVariable = exportVariable7; + exports2.exportVariable = exportVariable8; exports2.setSecret = setSecret; exports2.addPath = addPath; exports2.getInput = getInput2; @@ -21353,7 +21353,7 @@ var require_core = __commonJS({ ExitCode2[ExitCode2["Success"] = 0] = "Success"; ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; })(ExitCode || (exports2.ExitCode = ExitCode = {})); - function exportVariable7(name, val) { + function exportVariable8(name, val) { const convertedVal = (0, utils_1.toCommandValue)(val); process.env[name] = convertedVal; const filePath = process.env["GITHUB_ENV"] || ""; @@ -47343,7 +47343,7 @@ var require_internal_glob_options_helper = __commonJS({ })(); Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getOptions = getOptions; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); function getOptions(copy) { const result = { followSymbolicLinks: true, @@ -47355,23 +47355,23 @@ var require_internal_glob_options_helper = __commonJS({ if (copy) { if (typeof copy.followSymbolicLinks === "boolean") { result.followSymbolicLinks = copy.followSymbolicLinks; - core15.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); + core16.debug(`followSymbolicLinks '${result.followSymbolicLinks}'`); } if (typeof copy.implicitDescendants === "boolean") { result.implicitDescendants = copy.implicitDescendants; - core15.debug(`implicitDescendants '${result.implicitDescendants}'`); + core16.debug(`implicitDescendants '${result.implicitDescendants}'`); } if (typeof copy.matchDirectories === "boolean") { result.matchDirectories = copy.matchDirectories; - core15.debug(`matchDirectories '${result.matchDirectories}'`); + core16.debug(`matchDirectories '${result.matchDirectories}'`); } if (typeof copy.omitBrokenSymbolicLinks === "boolean") { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; - core15.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); + core16.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } if (typeof copy.excludeHiddenFiles === "boolean") { result.excludeHiddenFiles = copy.excludeHiddenFiles; - core15.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + core16.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); } } return result; @@ -48999,7 +48999,7 @@ var require_internal_globber = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.DefaultGlobber = void 0; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var fs14 = __importStar2(require("fs")); var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var path13 = __importStar2(require("path")); @@ -49052,7 +49052,7 @@ var require_internal_globber = __commonJS({ } const stack = []; for (const searchPath of patternHelper.getSearchPaths(patterns)) { - core15.debug(`Search path '${searchPath}'`); + core16.debug(`Search path '${searchPath}'`); try { yield __await2(fs14.promises.lstat(searchPath)); } catch (err) { @@ -49127,7 +49127,7 @@ var require_internal_globber = __commonJS({ } catch (err) { if (err.code === "ENOENT") { if (options.omitBrokenSymbolicLinks) { - core15.debug(`Broken symlink '${item.path}'`); + core16.debug(`Broken symlink '${item.path}'`); return void 0; } throw new Error(`No information found for the path '${item.path}'. This may indicate a broken symbolic link.`); @@ -49143,7 +49143,7 @@ var require_internal_globber = __commonJS({ traversalChain.pop(); } if (traversalChain.some((x) => x === realPath)) { - core15.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); + core16.debug(`Symlink cycle detected for path '${item.path}' and realpath '${realPath}'`); return void 0; } traversalChain.push(realPath); @@ -49246,7 +49246,7 @@ var require_internal_hash_files = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.hashFiles = hashFiles; var crypto2 = __importStar2(require("crypto")); - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var fs14 = __importStar2(require("fs")); var stream2 = __importStar2(require("stream")); var util = __importStar2(require("util")); @@ -49255,7 +49255,7 @@ var require_internal_hash_files = __commonJS({ return __awaiter2(this, arguments, void 0, function* (globber, currentWorkspace, verbose = false) { var _a, e_1, _b, _c; var _d; - const writeDelegate = verbose ? core15.info : core15.debug; + const writeDelegate = verbose ? core16.info : core16.debug; let hasMatch = false; const githubWorkspace = currentWorkspace ? currentWorkspace : (_d = process.env["GITHUB_WORKSPACE"]) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto2.createHash("sha256"); @@ -50646,7 +50646,7 @@ var require_cacheUtils = __commonJS({ exports2.assertDefined = assertDefined; exports2.getCacheVersion = getCacheVersion; exports2.getRuntimeToken = getRuntimeToken; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var exec = __importStar2(require_exec()); var glob = __importStar2(require_glob()); var io6 = __importStar2(require_io()); @@ -50697,7 +50697,7 @@ var require_cacheUtils = __commonJS({ _e = false; const file = _c; const relativeFile = path13.relative(workspace, file).replace(new RegExp(`\\${path13.sep}`, "g"), "/"); - core15.debug(`Matched: ${relativeFile}`); + core16.debug(`Matched: ${relativeFile}`); if (relativeFile === "") { paths.push("."); } else { @@ -50725,7 +50725,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, arguments, void 0, function* (app, additionalArgs = []) { let versionOutput = ""; additionalArgs.push("--version"); - core15.debug(`Checking ${app} ${additionalArgs.join(" ")}`); + core16.debug(`Checking ${app} ${additionalArgs.join(" ")}`); try { yield exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, @@ -50736,10 +50736,10 @@ var require_cacheUtils = __commonJS({ } }); } catch (err) { - core15.debug(err.message); + core16.debug(err.message); } versionOutput = versionOutput.trim(); - core15.debug(versionOutput); + core16.debug(versionOutput); return versionOutput; }); } @@ -50747,7 +50747,7 @@ var require_cacheUtils = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const versionOutput = yield getVersion("zstd", ["--quiet"]); const version = semver9.clean(versionOutput); - core15.debug(`zstd version: ${version}`); + core16.debug(`zstd version: ${version}`); if (versionOutput === "") { return constants_1.CompressionMethod.Gzip; } else { @@ -60530,44 +60530,44 @@ var require_fxp = __commonJS({ "node_modules/fast-xml-parser/lib/fxp.cjs"(exports2, module2) { (() => { "use strict"; - var t = { d: (e2, n2) => { - for (var i2 in n2) t.o(n2, i2) && !t.o(e2, i2) && Object.defineProperty(e2, i2, { enumerable: true, get: n2[i2] }); + var t = { d: (e2, i2) => { + for (var n2 in i2) t.o(i2, n2) && !t.o(e2, n2) && Object.defineProperty(e2, n2, { enumerable: true, get: i2[n2] }); }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => gt, XMLParser: () => it, XMLValidator: () => xt }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); + t.r(e), t.d(e, { XMLBuilder: () => Ot, XMLParser: () => ft, XMLValidator: () => $t }); + const i = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", n = new RegExp("^[" + i + "][" + i + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { + const i2 = []; + let n2 = e2.exec(t2); + for (; n2; ) { const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); + s2.startIndex = e2.lastIndex - n2[0].length; + const r2 = n2.length; + for (let t3 = 0; t3 < r2; t3++) s2.push(n2[t3]); + i2.push(s2), n2 = e2.exec(t2); } - return n2; + return i2; } const r = function(t2) { - return !(null == i.exec(t2)); - }, o = { allowBooleanAttributes: false, unpairedTags: [] }; - function a(t2, e2) { - e2 = Object.assign({}, o, e2); - const n2 = []; - let i2 = false, s2 = false; + return !(null == n.exec(t2)); + }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + function l(t2, e2) { + e2 = Object.assign({}, h, e2); + const i2 = []; + let n2 = false, s2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { if (r2 += 2, r2 = u(t2, r2), r2.err) return r2; } else { if ("<" !== t2[r2]) { - if (l(t2[r2])) continue; - return m("InvalidChar", "char '" + t2[r2] + "' is not expected.", N(t2, r2)); + if (p(t2[r2])) continue; + return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); } { let o2 = r2; if (r2++, "!" === t2[r2]) { - r2 = d(t2, r2); + r2 = c(t2, r2); continue; } { @@ -60575,63 +60575,63 @@ var require_fxp = __commonJS({ "/" === t2[r2] && (a2 = true, r2++); let h2 = ""; for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !b(h2)) { + if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !y(h2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", m("InvalidTag", e3, N(t2, r2)); + return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); } - const p2 = c(t2, r2); - if (false === p2) return m("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", N(t2, r2)); - let f2 = p2.value; - if (r2 = p2.index, "/" === f2[f2.length - 1]) { - const n3 = r2 - f2.length; - f2 = f2.substring(0, f2.length - 1); - const s3 = g(f2, e2); - if (true !== s3) return m(s3.err.code, s3.err.msg, N(t2, n3 + s3.err.line)); - i2 = true; + const l2 = g(t2, r2); + if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); + let d2 = l2.value; + if (r2 = l2.index, "/" === d2[d2.length - 1]) { + const i3 = r2 - d2.length; + d2 = d2.substring(0, d2.length - 1); + const s3 = x(d2, e2); + if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, i3 + s3.err.line)); + n2 = true; } else if (a2) { - if (!p2.tagClosed) return m("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", N(t2, r2)); - if (f2.trim().length > 0) return m("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", N(t2, o2)); - if (0 === n2.length) return m("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", N(t2, o2)); + if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); + if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); + if (0 === i2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); { - const e3 = n2.pop(); + const e3 = i2.pop(); if (h2 !== e3.tagName) { - let n3 = N(t2, e3.tagStartPos); - return m("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", N(t2, o2)); + let i3 = w(t2, e3.tagStartPos); + return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + i3.line + ", col " + i3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == i2.length && (s2 = true); } } else { - const a3 = g(f2, e2); - if (true !== a3) return m(a3.err.code, a3.err.msg, N(t2, r2 - f2.length + a3.err.line)); - if (true === s2) return m("InvalidXml", "Multiple possible root nodes found.", N(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; + const a3 = x(d2, e2); + if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); + if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); + -1 !== e2.unpairedTags.indexOf(h2) || i2.push({ tagName: h2, tagStartPos: o2 }), n2 = true; } for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { if ("!" === t2[r2 + 1]) { - r2++, r2 = d(t2, r2); + r2++, r2 = c(t2, r2); continue; } if ("?" !== t2[r2 + 1]) break; if (r2 = u(t2, ++r2), r2.err) return r2; } else if ("&" === t2[r2]) { - const e3 = x(t2, r2); - if (-1 == e3) return m("InvalidChar", "char '&' is not expected.", N(t2, r2)); + const e3 = N(t2, r2); + if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); r2 = e3; - } else if (true === s2 && !l(t2[r2])) return m("InvalidXml", "Extra text at the end", N(t2, r2)); + } else if (true === s2 && !p(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); "<" === t2[r2] && r2--; } } } - return i2 ? 1 == n2.length ? m("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || m("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : m("InvalidXml", "Start tag expected.", 1); + return n2 ? 1 == i2.length ? b("InvalidTag", "Unclosed tag '" + i2[0].tagName + "'.", w(t2, i2[0].tagStartPos)) : !(i2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(i2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); } - function l(t2) { + function p(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function u(t2, e2) { - const n2 = e2; + const i2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { - const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return m("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); + const n2 = t2.substr(i2, e2 - i2); + if (e2 > 5 && "xml" === n2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -60640,16 +60640,16 @@ var require_fxp = __commonJS({ } return e2; } - function d(t2, e2) { + function c(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; break; } } else if (t2.length > e2 + 8 && "D" === t2[e2 + 1] && "O" === t2[e2 + 2] && "C" === t2[e2 + 3] && "T" === t2[e2 + 4] && "Y" === t2[e2 + 5] && "P" === t2[e2 + 6] && "E" === t2[e2 + 7]) { - let n2 = 1; - for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) n2++; - else if (">" === t2[e2] && (n2--, 0 === n2)) break; + let i2 = 1; + for (e2 += 8; e2 < t2.length; e2++) if ("<" === t2[e2]) i2++; + else if (">" === t2[e2] && (i2--, 0 === i2)) break; } else if (t2.length > e2 + 9 && "[" === t2[e2 + 1] && "C" === t2[e2 + 2] && "D" === t2[e2 + 3] && "A" === t2[e2 + 4] && "T" === t2[e2 + 5] && "A" === t2[e2 + 6] && "[" === t2[e2 + 7]) { for (e2 += 8; e2 < t2.length; e2++) if ("]" === t2[e2] && "]" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -60658,83 +60658,90 @@ var require_fxp = __commonJS({ } return e2; } - const h = '"', p = "'"; - function c(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', f = "'"; + function g(t2, e2) { + let i2 = "", n2 = "", s2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === h || t2[e2] === p) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); - else if (">" === t2[e2] && "" === i2) { + if (t2[e2] === d || t2[e2] === f) "" === n2 ? n2 = t2[e2] : n2 !== t2[e2] || (n2 = ""); + else if (">" === t2[e2] && "" === n2) { s2 = true; break; } - n2 += t2[e2]; + i2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === n2 && { value: i2, index: e2, tagClosed: s2 }; } - const f = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function g(t2, e2) { - const n2 = s(t2, f), i2 = {}; - for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", y(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return m("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", y(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return m("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", y(n2[t3])); - const s2 = n2[t3][2]; - if (!E(s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", y(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return m("InvalidAttr", "Attribute '" + s2 + "' is repeated.", y(n2[t3])); - i2[s2] = 1; + const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); + function x(t2, e2) { + const i2 = s(t2, m), n2 = {}; + for (let t3 = 0; t3 < i2.length; t3++) { + if (0 === i2[t3][1].length) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' has no space in starting.", v(i2[t3])); + if (void 0 !== i2[t3][3] && void 0 === i2[t3][4]) return b("InvalidAttr", "Attribute '" + i2[t3][2] + "' is without value.", v(i2[t3])); + if (void 0 === i2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + i2[t3][2] + "' is not allowed.", v(i2[t3])); + const s2 = i2[t3][2]; + if (!E(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(i2[t3])); + if (Object.prototype.hasOwnProperty.call(n2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(i2[t3])); + n2[s2] = 1; } return true; } - function x(t2, e2) { + function N(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { - let n3 = /\d/; - for ("x" === t3[e3] && (e3++, n3 = /[\da-fA-F]/); e3 < t3.length; e3++) { + let i3 = /\d/; + for ("x" === t3[e3] && (e3++, i3 = /[\da-fA-F]/); e3 < t3.length; e3++) { if (";" === t3[e3]) return e3; - if (!t3[e3].match(n3)) break; + if (!t3[e3].match(i3)) break; } return -1; })(t2, ++e2); - let n2 = 0; - for (; e2 < t2.length; e2++, n2++) if (!(t2[e2].match(/\w/) && n2 < 20)) { + let i2 = 0; + for (; e2 < t2.length; e2++, i2++) if (!(t2[e2].match(/\w/) && i2 < 20)) { if (";" === t2[e2]) break; return -1; } return e2; } - function m(t2, e2, n2) { - return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; + function b(t2, e2, i2) { + return { err: { code: t2, msg: e2, line: i2.line || i2, col: i2.col } }; } function E(t2) { return r(t2); } - function b(t2) { + function y(t2) { return r(t2); } - function N(t2, e2) { - const n2 = t2.substring(0, e2).split(/\r?\n/); - return { line: n2.length, col: n2[n2.length - 1].length + 1 }; + function w(t2, e2) { + const i2 = t2.substring(0, e2).split(/\r?\n/); + return { line: i2.length, col: i2[i2.length - 1].length + 1 }; } - function y(t2) { + function v(t2) { return t2.startIndex + t2[1].length; } - const T = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const T = (t2) => o.includes(t2) ? "__" + t2 : t2, P = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { + }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, i2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true }; - function w(t2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : w(true); - } - const v = function(t2) { - const e2 = Object.assign({}, T, t2); - return e2.processEntities = w(e2.processEntities), e2; + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: T }; + function S(t2, e2) { + if ("string" != typeof t2) return; + const i2 = t2.toLowerCase(); + if (o.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + if (a.some((t3) => i2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + } + function A(t2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 10, maxTotalExpansions: 1e3, maxExpandedLength: 1e5, maxEntityCount: 100, allowedTags: null, tagFilter: null } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: t2.maxEntitySize ?? 1e4, maxExpansionDepth: t2.maxExpansionDepth ?? 10, maxTotalExpansions: t2.maxTotalExpansions ?? 1e3, maxExpandedLength: t2.maxExpandedLength ?? 1e5, maxEntityCount: t2.maxEntityCount ?? 100, allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null } : A(true); + } + const C = function(t2) { + const e2 = Object.assign({}, P, t2), i2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of i2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = T), e2.processEntities = A(e2.processEntities), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; let O; O = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class I { + class $ { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -60748,190 +60755,399 @@ var require_fxp = __commonJS({ return O; } } - class P { + class I { constructor(t2) { this.suppressValidationErr = !t2, this.options = t2; } readDocType(t2, e2) { - const n2 = /* @__PURE__ */ Object.create(null); + const i2 = /* @__PURE__ */ Object.create(null); + let n2 = 0; if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let i2 = 1, s2 = false, r2 = false, o2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || r2) if (">" === t2[e2]) { - if (r2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (r2 = false, i2--) : i2--, 0 === i2) break; - } else "[" === t2[e2] ? s2 = true : o2 += t2[e2]; + let s2 = 1, r2 = false, o2 = false, a2 = ""; + for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; + } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; else { - if (s2 && S(t2, "!ENTITY", e2)) { - let i3, s3; - if (e2 += 7, [i3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { - const t3 = i3.replace(/[.\-+*:]/g, "\\."); - n2[i3] = { regx: RegExp(`&${t3};`, "g"), val: s3 }; + if (r2 && _(t2, "!ENTITY", e2)) { + let s3, r3; + if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (false !== this.options.enabled && this.options.maxEntityCount && n2 >= this.options.maxEntityCount) throw new Error(`Entity count (${n2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); + const t3 = s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + i2[s3] = { regx: RegExp(`&${t3};`, "g"), val: r3 }, n2++; } - } else if (s2 && S(t2, "!ELEMENT", e2)) { + } else if (r2 && _(t2, "!ELEMENT", e2)) { e2 += 8; - const { index: n3 } = this.readElementExp(t2, e2 + 1); - e2 = n3; - } else if (s2 && S(t2, "!ATTLIST", e2)) e2 += 8; - else if (s2 && S(t2, "!NOTATION", e2)) { + const { index: i3 } = this.readElementExp(t2, e2 + 1); + e2 = i3; + } else if (r2 && _(t2, "!ATTLIST", e2)) e2 += 8; + else if (r2 && _(t2, "!NOTATION", e2)) { e2 += 9; - const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); - e2 = n3; + const { index: i3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); + e2 = i3; } else { - if (!S(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); - r2 = true; + if (!_(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + o2 = true; } - i2++, o2 = ""; + s2++, a2 = ""; } - if (0 !== i2) throw new Error("Unclosed DOCTYPE"); + if (0 !== s2) throw new Error("Unclosed DOCTYPE"); } - return { entities: n2, i: e2 }; + return { entities: i2, i: e2 }; } readEntityExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) n2 += t2[e2], e2++; - if (C(n2), e2 = A(t2, e2), !this.suppressValidationErr) { + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) i2 += t2[e2], e2++; + if (D(i2), e2 = j(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let i2 = ""; - if ([e2, i2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && i2.length > this.options.maxEntitySize) throw new Error(`Entity "${n2}" size (${i2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [n2, i2, --e2]; + let n2 = ""; + if ([e2, n2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && this.options.maxEntitySize && n2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${n2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, n2, --e2]; } readNotationExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - !this.suppressValidationErr && C(n2), e2 = A(t2, e2); - const i2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== i2 && "PUBLIC" !== i2) throw new Error(`Expected SYSTEM or PUBLIC, found "${i2}"`); - e2 += i2.length, e2 = A(t2, e2); + e2 = j(t2, e2); + let i2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + !this.suppressValidationErr && D(i2), e2 = j(t2, e2); + const n2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== n2 && "PUBLIC" !== n2) throw new Error(`Expected SYSTEM or PUBLIC, found "${n2}"`); + e2 += n2.length, e2 = j(t2, e2); let s2 = null, r2 = null; - if ("PUBLIC" === i2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = A(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === i2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: n2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; + if ("PUBLIC" === n2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = j(t2, e2)] && "'" !== t2[e2] || ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === n2 && ([e2, r2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !r2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: r2, index: --e2 }; } - readIdentifierVal(t2, e2, n2) { - let i2 = ""; + readIdentifierVal(t2, e2, i2) { + let n2 = ""; const s2 = t2[e2]; if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - for (e2++; e2 < t2.length && t2[e2] !== s2; ) i2 += t2[e2], e2++; - if (t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); - return [++e2, i2]; + for (e2++; e2 < t2.length && t2[e2] !== s2; ) n2 += t2[e2], e2++; + if (t2[e2] !== s2) throw new Error(`Unterminated ${i2} value`); + return [++e2, n2]; } readElementExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - if (!this.suppressValidationErr && !r(n2)) throw new Error(`Invalid element name: "${n2}"`); + e2 = j(t2, e2); let i2 = ""; - if ("E" === t2[e2 = A(t2, e2)] && S(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && S(t2, "NY", e2)) e2 += 2; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; + if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); + let n2 = ""; + if ("E" === t2[e2 = j(t2, e2)] && _(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && _(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { - for (e2++; e2 < t2.length && ")" !== t2[e2]; ) i2 += t2[e2], e2++; + for (e2++; e2 < t2.length && ")" !== t2[e2]; ) n2 += t2[e2], e2++; if (")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: n2, contentModel: i2.trim(), index: e2 }; + return { elementName: i2, contentModel: n2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - e2 = A(t2, e2); - let n2 = ""; - for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; - C(n2), e2 = A(t2, e2); + e2 = j(t2, e2); let i2 = ""; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) i2 += t2[e2], e2++; - if (!C(i2)) throw new Error(`Invalid attribute name: "${i2}"`); - e2 = A(t2, e2); + D(i2), e2 = j(t2, e2); + let n2 = ""; + for (; e2 < t2.length && !/\s/.test(t2[e2]); ) n2 += t2[e2], e2++; + if (!D(n2)) throw new Error(`Invalid attribute name: "${n2}"`); + e2 = j(t2, e2); let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (s2 = "NOTATION", "(" !== t2[e2 = A(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = j(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; - let n3 = []; + let i3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { - let i3 = ""; - for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) i3 += t2[e2], e2++; - if (i3 = i3.trim(), !C(i3)) throw new Error(`Invalid notation name: "${i3}"`); - n3.push(i3), "|" === t2[e2] && (e2++, e2 = A(t2, e2)); + let n3 = ""; + for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) n3 += t2[e2], e2++; + if (n3 = n3.trim(), !D(n3)) throw new Error(`Invalid notation name: "${n3}"`); + i3.push(n3), "|" === t2[e2] && (e2++, e2 = j(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, s2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + i3.join("|") + ")"; } else { for (; e2 < t2.length && !/\s/.test(t2[e2]); ) s2 += t2[e2], e2++; - const n3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !n3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); + const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = A(t2, e2); + e2 = j(t2, e2); let r2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: n2, attributeName: i2, attributeType: s2, defaultValue: r2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (r2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (r2 = "#IMPLIED", e2 += 7) : [e2, r2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: n2, attributeType: s2, defaultValue: r2, index: e2 }; } } - const A = (t2, e2) => { + const j = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function S(t2, e2, n2) { - for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; + function _(t2, e2, i2) { + for (let n2 = 0; n2 < e2.length; n2++) if (e2[n2] !== t2[i2 + n2 + 1]) return false; return true; } - function C(t2) { + function D(t2) { if (r(t2)) return t2; throw new Error(`Invalid entity name ${t2}`); } - const $ = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, D = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; - const j = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class L { + const V = /^[-+]?0x[a-fA-F0-9]+$/, k = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, F = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true }; + const L = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + class M { + constructor(t2 = {}) { + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = []; + } + push(t2, e2 = null, i2 = null) { + this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); + const n2 = this.path.length; + this.siblingStacks[n2] || (this.siblingStacks[n2] = /* @__PURE__ */ new Map()); + const s2 = this.siblingStacks[n2], r2 = i2 ? `${i2}:${t2}` : t2, o2 = s2.get(r2) || 0; + let a2 = 0; + for (const t3 of s2.values()) a2 += t3; + s2.set(r2, o2 + 1); + const h2 = { tag: t2, position: a2, counter: o2 }; + null != i2 && (h2.namespace = i2), null != e2 && (h2.values = e2), this.path.push(h2); + } + pop() { + if (0 === this.path.length) return; + const t2 = this.path.pop(); + return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + } + updateCurrent(t2) { + if (this.path.length > 0) { + const e2 = this.path[this.path.length - 1]; + null != t2 && (e2.values = t2); + } + } + getCurrentTag() { + return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0; + } + getCurrentNamespace() { + return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0; + } + getAttrValue(t2) { + if (0 === this.path.length) return; + const e2 = this.path[this.path.length - 1]; + return e2.values?.[t2]; + } + hasAttr(t2) { + if (0 === this.path.length) return false; + const e2 = this.path[this.path.length - 1]; + return void 0 !== e2.values && t2 in e2.values; + } + getPosition() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; + } + getCounter() { + return 0 === this.path.length ? -1 : this.path[this.path.length - 1].counter ?? 0; + } + getIndex() { + return this.getPosition(); + } + getDepth() { + return this.path.length; + } + toString(t2, e2 = true) { + const i2 = t2 || this.separator; + return this.path.map((t3) => e2 && t3.namespace ? `${t3.namespace}:${t3.tag}` : t3.tag).join(i2); + } + toArray() { + return this.path.map((t2) => t2.tag); + } + reset() { + this.path = [], this.siblingStacks = []; + } + matches(t2) { + const e2 = t2.segments; + return 0 !== e2.length && (t2.hasDeepWildcard() ? this._matchWithDeepWildcard(e2) : this._matchSimple(e2)); + } + _matchSimple(t2) { + if (this.path.length !== t2.length) return false; + for (let e2 = 0; e2 < t2.length; e2++) { + const i2 = t2[e2], n2 = this.path[e2], s2 = e2 === this.path.length - 1; + if (!this._matchSegment(i2, n2, s2)) return false; + } + return true; + } + _matchWithDeepWildcard(t2) { + let e2 = this.path.length - 1, i2 = t2.length - 1; + for (; i2 >= 0 && e2 >= 0; ) { + const n2 = t2[i2]; + if ("deep-wildcard" === n2.type) { + if (i2--, i2 < 0) return true; + const n3 = t2[i2]; + let s2 = false; + for (let t3 = e2; t3 >= 0; t3--) { + const r2 = t3 === this.path.length - 1; + if (this._matchSegment(n3, this.path[t3], r2)) { + e2 = t3 - 1, i2--, s2 = true; + break; + } + } + if (!s2) return false; + } else { + const t3 = e2 === this.path.length - 1; + if (!this._matchSegment(n2, this.path[e2], t3)) return false; + e2--, i2--; + } + } + return i2 < 0; + } + _matchSegment(t2, e2, i2) { + if ("*" !== t2.tag && t2.tag !== e2.tag) return false; + if (void 0 !== t2.namespace && "*" !== t2.namespace && t2.namespace !== e2.namespace) return false; + if (void 0 !== t2.attrName) { + if (!i2) return false; + if (!e2.values || !(t2.attrName in e2.values)) return false; + if (void 0 !== t2.attrValue) { + const i3 = e2.values[t2.attrName]; + if (String(i3) !== String(t2.attrValue)) return false; + } + } + if (void 0 !== t2.position) { + if (!i2) return false; + const n2 = e2.counter ?? 0; + if ("first" === t2.position && 0 !== n2) return false; + if ("odd" === t2.position && n2 % 2 != 1) return false; + if ("even" === t2.position && n2 % 2 != 0) return false; + if ("nth" === t2.position && n2 !== t2.positionValue) return false; + } + return true; + } + snapshot() { + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + } + restore(t2) { + this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + } + } + class G { + constructor(t2, e2 = {}) { + this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); + } + _parse(t2) { + const e2 = []; + let i2 = 0, n2 = ""; + for (; i2 < t2.length; ) t2[i2] === this.separator ? i2 + 1 < t2.length && t2[i2 + 1] === this.separator ? (n2.trim() && (e2.push(this._parseSegment(n2.trim())), n2 = ""), e2.push({ type: "deep-wildcard" }), i2 += 2) : (n2.trim() && e2.push(this._parseSegment(n2.trim())), n2 = "", i2++) : (n2 += t2[i2], i2++); + return n2.trim() && e2.push(this._parseSegment(n2.trim())), e2; + } + _parseSegment(t2) { + const e2 = { type: "tag" }; + let i2 = null, n2 = t2; + const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (s2 && (n2 = s2[1] + s2[3], s2[2])) { + const t3 = s2[2].slice(1, -1); + t3 && (i2 = t3); + } + let r2, o2, a2 = n2; + if (n2.includes("::")) { + const e3 = n2.indexOf("::"); + if (r2 = n2.substring(0, e3).trim(), a2 = n2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + } + let h2 = null; + if (a2.includes(":")) { + const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), i3 = a2.substring(t3 + 1).trim(); + ["first", "last", "odd", "even"].includes(i3) || /^nth\(\d+\)$/.test(i3) ? (o2 = e3, h2 = i3) : o2 = a2; + } else o2 = a2; + if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); + if (e2.tag = o2, r2 && (e2.namespace = r2), i2) if (i2.includes("=")) { + const t3 = i2.indexOf("="); + e2.attrName = i2.substring(0, t3).trim(), e2.attrValue = i2.substring(t3 + 1).trim(); + } else e2.attrName = i2.trim(); + if (h2) { + const t3 = h2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + } + return e2; + } + get length() { + return this.segments.length; + } + hasDeepWildcard() { + return this._hasDeepWildcard; + } + hasAttributeCondition() { + return this._hasAttributeCondition; + } + hasPositionSelector() { + return this._hasPositionSelector; + } + toString() { + return this.pattern; + } + } + function R(t2, e2) { + if (!t2) return {}; + const i2 = e2.attributesGroupName ? t2[e2.attributesGroupName] : t2; + if (!i2) return {}; + const n2 = {}; + for (const t3 in i2) t3.startsWith(e2.attributeNamePrefix) ? n2[t3.substring(e2.attributeNamePrefix.length)] = i2[t3] : n2[t3] = i2[t3]; + return n2; + } + function U(t2) { + if (!t2 || "string" != typeof t2) return; + const e2 = t2.indexOf(":"); + if (-1 !== e2 && e2 > 0) { + const i2 = t2.substring(0, e2); + if ("xmlns" !== i2) return i2; + } + } + class B { constructor(t2) { var e2; - if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => K(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => K(e3, 16, "&#x") } }, this.addExternalEntities = F, this.parseXml = R, this.parseTextData = M, this.resolveNameSpace = k, this.buildAttributesMap = U, this.isItStopNode = X, this.replaceEntitiesValue = Y, this.readStopNodeData = q, this.saveTextToParentTag = G, this.addChild = B, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + if (this.options = t2, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "\xA2" }, pound: { regex: /&(pound|#163);/g, val: "\xA3" }, yen: { regex: /&(yen|#165);/g, val: "\xA5" }, euro: { regex: /&(euro|#8364);/g, val: "\u20AC" }, copyright: { regex: /&(copy|#169);/g, val: "\xA9" }, reg: { regex: /&(reg|#174);/g, val: "\xAE" }, inr: { regex: /&(inr|#8377);/g, val: "\u20B9" }, num_dec: { regex: /&#([0-9]{1,7});/g, val: (t3, e3) => st(e3, 10, "&#") }, num_hex: { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (t3, e3) => st(e3, 16, "&#x") } }, this.addExternalEntities = W, this.parseXml = Z, this.parseTextData = Y, this.resolveNameSpace = X, this.buildAttributesMap = q, this.isItStopNode = H, this.replaceEntitiesValue = K, this.readStopNodeData = it, this.saveTextToParentTag = Q, this.addChild = J, this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.options.stopNodes && this.options.stopNodes.length > 0) { - this.stopNodesExact = /* @__PURE__ */ new Set(), this.stopNodesWildcard = /* @__PURE__ */ new Set(); + } : () => false, this.entityExpansionCount = 0, this.currentExpandedLength = 0, this.matcher = new M(), this.isCurrentNodeStopNode = false, this.options.stopNodes && this.options.stopNodes.length > 0) { + this.stopNodeExpressions = []; for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { const e3 = this.options.stopNodes[t3]; - "string" == typeof e3 && (e3.startsWith("*.") ? this.stopNodesWildcard.add(e3.substring(2)) : this.stopNodesExact.add(e3)); + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); } } } } - function F(t2) { + function W(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2], s2 = i2.replace(/[.\-+*:]/g, "\\."); - this.lastEntities[i2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[i2] }; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2], s2 = n2.replace(/[.\-+*:]/g, "\\."); + this.lastEntities[n2] = { regex: new RegExp("&" + s2 + ";", "g"), val: t2[n2] }; } } - function M(t2, e2, n2, i2, s2, r2, o2) { - if (void 0 !== t2 && (this.options.trimValues && !i2 && (t2 = t2.trim()), t2.length > 0)) { - o2 || (t2 = this.replaceEntitiesValue(t2, e2, n2)); - const i3 = this.options.tagValueProcessor(e2, t2, n2, s2, r2); - return null == i3 ? t2 : typeof i3 != typeof t2 || i3 !== t2 ? i3 : this.options.trimValues || t2.trim() === t2 ? Z(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; + function Y(t2, e2, i2, n2, s2, r2, o2) { + if (void 0 !== t2 && (this.options.trimValues && !n2 && (t2 = t2.trim()), t2.length > 0)) { + o2 || (t2 = this.replaceEntitiesValue(t2, e2, i2)); + const n3 = this.options.jPath ? i2.toString() : i2, a2 = this.options.tagValueProcessor(e2, t2, n3, s2, r2); + return null == a2 ? t2 : typeof a2 != typeof t2 || a2 !== t2 ? a2 : this.options.trimValues || t2.trim() === t2 ? nt(t2, this.options.parseTagValue, this.options.numberParseOptions) : t2; } } - function k(t2) { + function X(t2) { if (this.options.removeNSPrefix) { - const e2 = t2.split(":"), n2 = "/" === t2.charAt(0) ? "/" : ""; + const e2 = t2.split(":"), i2 = "/" === t2.charAt(0) ? "/" : ""; if ("xmlns" === e2[0]) return ""; - 2 === e2.length && (t2 = n2 + e2[1]); + 2 === e2.length && (t2 = i2 + e2[1]); } return t2; } - const _ = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); - function U(t2, e2, n2) { + const z = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm"); + function q(t2, e2, i2) { if (true !== this.options.ignoreAttributes && "string" == typeof t2) { - const i2 = s(t2, _), r2 = i2.length, o2 = {}; + const n2 = s(t2, z), r2 = n2.length, o2 = {}, a2 = {}; + for (let t3 = 0; t3 < r2; t3++) { + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = n2[t3][4]; + if (s2.length && void 0 !== r3) { + let t4 = r3; + this.options.trimValues && (t4 = t4.trim()), t4 = this.replaceEntitiesValue(t4, i2, e2), a2[s2] = t4; + } + } + Object.keys(a2).length > 0 && "object" == typeof e2 && e2.updateCurrent && e2.updateCurrent(a2); for (let t3 = 0; t3 < r2; t3++) { - const s2 = this.resolveNameSpace(i2[t3][1]); - if (this.ignoreAttributesFn(s2, e2)) continue; - let r3 = i2[t3][4], a2 = this.options.attributeNamePrefix + s2; - if (s2.length) if (this.options.transformAttributeName && (a2 = this.options.transformAttributeName(a2)), "__proto__" === a2 && (a2 = "#__proto__"), void 0 !== r3) { - this.options.trimValues && (r3 = r3.trim()), r3 = this.replaceEntitiesValue(r3, n2, e2); - const t4 = this.options.attributeValueProcessor(s2, r3, e2); - o2[a2] = null == t4 ? r3 : typeof t4 != typeof r3 || t4 !== r3 ? t4 : Z(r3, this.options.parseAttributeValue, this.options.numberParseOptions); - } else this.options.allowBooleanAttributes && (o2[a2] = true); + const s2 = this.resolveNameSpace(n2[t3][1]), r3 = this.options.jPath ? e2.toString() : e2; + if (this.ignoreAttributesFn(s2, r3)) continue; + let a3 = n2[t3][4], h2 = this.options.attributeNamePrefix + s2; + if (s2.length) if (this.options.transformAttributeName && (h2 = this.options.transformAttributeName(h2)), h2 = ot(h2, this.options), void 0 !== a3) { + this.options.trimValues && (a3 = a3.trim()), a3 = this.replaceEntitiesValue(a3, i2, e2); + const t4 = this.options.jPath ? e2.toString() : e2, n3 = this.options.attributeValueProcessor(s2, a3, t4); + o2[h2] = null == n3 ? a3 : typeof n3 != typeof a3 || n3 !== a3 ? n3 : nt(a3, this.options.parseAttributeValue, this.options.numberParseOptions); + } else this.options.allowBooleanAttributes && (o2[h2] = true); } if (!Object.keys(o2).length) return; if (this.options.attributesGroupName) { @@ -60941,290 +61157,325 @@ var require_fxp = __commonJS({ return o2; } } - const R = function(t2) { + const Z = function(t2) { t2 = t2.replace(/\r\n?/g, "\n"); - const e2 = new I("!xml"); - let n2 = e2, i2 = "", s2 = ""; - this.entityExpansionCount = 0, this.currentExpandedLength = 0; - const r2 = new P(this.options.processEntities); - for (let o2 = 0; o2 < t2.length; o2++) if ("<" === t2[o2]) if ("/" === t2[o2 + 1]) { - const e3 = z(t2, ">", o2, "Closing Tag is not closed."); - let r3 = t2.substring(o2 + 2, e3).trim(); + const e2 = new $("!xml"); + let i2 = e2, n2 = ""; + this.matcher.reset(), this.entityExpansionCount = 0, this.currentExpandedLength = 0; + const s2 = new I(this.options.processEntities); + for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2]) if ("/" === t2[r2 + 1]) { + const e3 = tt(t2, ">", r2, "Closing Tag is not closed."); + let s3 = t2.substring(r2 + 2, e3).trim(); if (this.options.removeNSPrefix) { - const t3 = r3.indexOf(":"); - -1 !== t3 && (r3 = r3.substr(t3 + 1)); - } - this.options.transformTagName && (r3 = this.options.transformTagName(r3)), n2 && (i2 = this.saveTextToParentTag(i2, n2, s2)); - const a2 = s2.substring(s2.lastIndexOf(".") + 1); - if (r3 && -1 !== this.options.unpairedTags.indexOf(r3)) throw new Error(`Unpaired tag can not be used as closing tag: `); - let l2 = 0; - a2 && -1 !== this.options.unpairedTags.indexOf(a2) ? (l2 = s2.lastIndexOf(".", s2.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l2 = s2.lastIndexOf("."), s2 = s2.substring(0, l2), n2 = this.tagsNodeStack.pop(), i2 = "", o2 = e3; - } else if ("?" === t2[o2 + 1]) { - let e3 = W(t2, o2, false, "?>"); + const t3 = s3.indexOf(":"); + -1 !== t3 && (s3 = s3.substr(t3 + 1)); + } + s3 = rt(this.options.transformTagName, s3, "", this.options).tagName, i2 && (n2 = this.saveTextToParentTag(n2, i2, this.matcher)); + const o2 = this.matcher.getCurrentTag(); + if (s3 && -1 !== this.options.unpairedTags.indexOf(s3)) throw new Error(`Unpaired tag can not be used as closing tag: `); + o2 && -1 !== this.options.unpairedTags.indexOf(o2) && (this.matcher.pop(), this.tagsNodeStack.pop()), this.matcher.pop(), this.isCurrentNodeStopNode = false, i2 = this.tagsNodeStack.pop(), n2 = "", r2 = e3; + } else if ("?" === t2[r2 + 1]) { + let e3 = et(t2, r2, false, "?>"); if (!e3) throw new Error("Pi Tag is not closed."); - if (i2 = this.saveTextToParentTag(i2, n2, s2), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; + if (n2 = this.saveTextToParentTag(n2, i2, this.matcher), this.options.ignoreDeclaration && "?xml" === e3.tagName || this.options.ignorePiTags) ; else { - const t3 = new I(e3.tagName); - t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, s2, e3.tagName)), this.addChild(n2, t3, s2, o2); + const t3 = new $(e3.tagName); + t3.add(this.options.textNodeName, ""), e3.tagName !== e3.tagExp && e3.attrExpPresent && (t3[":@"] = this.buildAttributesMap(e3.tagExp, this.matcher, e3.tagName)), this.addChild(i2, t3, this.matcher, r2); } - o2 = e3.closeIndex + 1; - } else if ("!--" === t2.substr(o2 + 1, 3)) { - const e3 = z(t2, "-->", o2 + 4, "Comment is not closed."); + r2 = e3.closeIndex + 1; + } else if ("!--" === t2.substr(r2 + 1, 3)) { + const e3 = tt(t2, "-->", r2 + 4, "Comment is not closed."); if (this.options.commentPropName) { - const r3 = t2.substring(o2 + 4, e3 - 2); - i2 = this.saveTextToParentTag(i2, n2, s2), n2.add(this.options.commentPropName, [{ [this.options.textNodeName]: r3 }]); - } - o2 = e3; - } else if ("!D" === t2.substr(o2 + 1, 2)) { - const e3 = r2.readDocType(t2, o2); - this.docTypeEntities = e3.entities, o2 = e3.i; - } else if ("![" === t2.substr(o2 + 1, 2)) { - const e3 = z(t2, "]]>", o2, "CDATA is not closed.") - 2, r3 = t2.substring(o2 + 9, e3); - i2 = this.saveTextToParentTag(i2, n2, s2); - let a2 = this.parseTextData(r3, n2.tagname, s2, true, false, true, true); - null == a2 && (a2 = ""), this.options.cdataPropName ? n2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: r3 }]) : n2.add(this.options.textNodeName, a2), o2 = e3 + 2; + const s3 = t2.substring(r2 + 4, e3 - 2); + n2 = this.saveTextToParentTag(n2, i2, this.matcher), i2.add(this.options.commentPropName, [{ [this.options.textNodeName]: s3 }]); + } + r2 = e3; + } else if ("!D" === t2.substr(r2 + 1, 2)) { + const e3 = s2.readDocType(t2, r2); + this.docTypeEntities = e3.entities, r2 = e3.i; + } else if ("![" === t2.substr(r2 + 1, 2)) { + const e3 = tt(t2, "]]>", r2, "CDATA is not closed.") - 2, s3 = t2.substring(r2 + 9, e3); + n2 = this.saveTextToParentTag(n2, i2, this.matcher); + let o2 = this.parseTextData(s3, i2.tagname, this.matcher, true, false, true, true); + null == o2 && (o2 = ""), this.options.cdataPropName ? i2.add(this.options.cdataPropName, [{ [this.options.textNodeName]: s3 }]) : i2.add(this.options.textNodeName, o2), r2 = e3 + 2; } else { - let r3 = W(t2, o2, this.options.removeNSPrefix), a2 = r3.tagName; - const l2 = r3.rawTagName; - let u2 = r3.tagExp, d2 = r3.attrExpPresent, h2 = r3.closeIndex; - if (this.options.transformTagName) { - const t3 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t3), a2 = t3; - } - if (this.options.strictReservedNames && (a2 === this.options.commentPropName || a2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${a2}`); - n2 && i2 && "!xml" !== n2.tagname && (i2 = this.saveTextToParentTag(i2, n2, s2, false)); - const p2 = n2; - p2 && -1 !== this.options.unpairedTags.indexOf(p2.tagname) && (n2 = this.tagsNodeStack.pop(), s2 = s2.substring(0, s2.lastIndexOf("."))), a2 !== e2.tagname && (s2 += s2 ? "." + a2 : a2); - const c2 = o2; - if (this.isItStopNode(this.stopNodesExact, this.stopNodesWildcard, s2, a2)) { + let s3 = et(t2, r2, this.options.removeNSPrefix); + if (!s3) { + const e3 = t2.substring(Math.max(0, r2 - 50), Math.min(t2.length, r2 + 50)); + throw new Error(`readTagExp returned undefined at position ${r2}. Context: "${e3}"`); + } + let o2 = s3.tagName; + const a2 = s3.rawTagName; + let h2 = s3.tagExp, l2 = s3.attrExpPresent, p2 = s3.closeIndex; + if ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options), this.options.strictReservedNames && (o2 === this.options.commentPropName || o2 === this.options.cdataPropName)) throw new Error(`Invalid tag name: ${o2}`); + i2 && n2 && "!xml" !== i2.tagname && (n2 = this.saveTextToParentTag(n2, i2, this.matcher, false)); + const u2 = i2; + u2 && -1 !== this.options.unpairedTags.indexOf(u2.tagname) && (i2 = this.tagsNodeStack.pop(), this.matcher.pop()); + let c2 = false; + h2.length > 0 && h2.lastIndexOf("/") === h2.length - 1 && (c2 = true, "/" === o2[o2.length - 1] ? (o2 = o2.substr(0, o2.length - 1), h2 = o2) : h2 = h2.substr(0, h2.length - 1), l2 = o2 !== h2); + let d2, f2 = null, g2 = {}; + d2 = U(a2), o2 !== e2.tagname && this.matcher.push(o2, {}, d2), o2 !== h2 && l2 && (f2 = this.buildAttributesMap(h2, this.matcher, o2), f2 && (g2 = R(f2, this.options))), o2 !== e2.tagname && (this.isCurrentNodeStopNode = this.isItStopNode(this.stopNodeExpressions, this.matcher)); + const m2 = r2; + if (this.isCurrentNodeStopNode) { let e3 = ""; - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) "/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), o2 = r3.closeIndex; - else if (-1 !== this.options.unpairedTags.indexOf(a2)) o2 = r3.closeIndex; + if (c2) r2 = s3.closeIndex; + else if (-1 !== this.options.unpairedTags.indexOf(o2)) r2 = s3.closeIndex; else { - const n3 = this.readStopNodeData(t2, l2, h2 + 1); - if (!n3) throw new Error(`Unexpected end of ${l2}`); - o2 = n3.i, e3 = n3.tagContent; + const i3 = this.readStopNodeData(t2, a2, p2 + 1); + if (!i3) throw new Error(`Unexpected end of ${a2}`); + r2 = i3.i, e3 = i3.tagContent; } - const i3 = new I(a2); - a2 !== u2 && d2 && (i3[":@"] = this.buildAttributesMap(u2, s2, a2)), e3 && (e3 = this.parseTextData(e3, a2, s2, true, d2, true, true)), s2 = s2.substr(0, s2.lastIndexOf(".")), i3.add(this.options.textNodeName, e3), this.addChild(n2, i3, s2, c2); + const n3 = new $(o2); + f2 && (n3[":@"] = f2), n3.add(this.options.textNodeName, e3), this.matcher.pop(), this.isCurrentNodeStopNode = false, this.addChild(i2, n3, this.matcher, m2); } else { - if (u2.length > 0 && u2.lastIndexOf("/") === u2.length - 1) { - if ("/" === a2[a2.length - 1] ? (a2 = a2.substr(0, a2.length - 1), s2 = s2.substr(0, s2.length - 1), u2 = a2) : u2 = u2.substr(0, u2.length - 1), this.options.transformTagName) { - const t4 = this.options.transformTagName(a2); - u2 === a2 && (u2 = t4), a2 = t4; - } - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")); + if (c2) { + ({ tagName: o2, tagExp: h2 } = rt(this.options.transformTagName, o2, h2, this.options)); + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false; } else { - if (-1 !== this.options.unpairedTags.indexOf(a2)) { - const t3 = new I(a2); - a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2)), this.addChild(n2, t3, s2, c2), s2 = s2.substr(0, s2.lastIndexOf(".")), o2 = r3.closeIndex; + if (-1 !== this.options.unpairedTags.indexOf(o2)) { + const t3 = new $(o2); + f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), this.matcher.pop(), this.isCurrentNodeStopNode = false, r2 = s3.closeIndex; continue; } { - const t3 = new I(a2); + const t3 = new $(o2); if (this.tagsNodeStack.length > this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); - this.tagsNodeStack.push(n2), a2 !== u2 && d2 && (t3[":@"] = this.buildAttributesMap(u2, s2, a2)), this.addChild(n2, t3, s2, c2), n2 = t3; + this.tagsNodeStack.push(i2), f2 && (t3[":@"] = f2), this.addChild(i2, t3, this.matcher, m2), i2 = t3; } } - i2 = "", o2 = h2; + n2 = "", r2 = p2; } } - else i2 += t2[o2]; + else n2 += t2[r2]; return e2.child; }; - function B(t2, e2, n2, i2) { - this.options.captureMetaData || (i2 = void 0); - const s2 = this.options.updateTag(e2.tagname, n2, e2[":@"]); - false === s2 || ("string" == typeof s2 ? (e2.tagname = s2, t2.addChild(e2, i2)) : t2.addChild(e2, i2)); - } - const Y = function(t2, e2, n2) { - if (-1 === t2.indexOf("&")) return t2; - const i2 = this.options.processEntities; - if (!i2.enabled) return t2; - if (i2.allowedTags && !i2.allowedTags.includes(e2)) return t2; - if (i2.tagFilter && !i2.tagFilter(e2, n2)) return t2; - for (let e3 in this.docTypeEntities) { - const n3 = this.docTypeEntities[e3], s2 = t2.match(n3.regx); + function J(t2, e2, i2, n2) { + this.options.captureMetaData || (n2 = void 0); + const s2 = this.options.jPath ? i2.toString() : i2, r2 = this.options.updateTag(e2.tagname, s2, e2[":@"]); + false === r2 || ("string" == typeof r2 ? (e2.tagname = r2, t2.addChild(e2, n2)) : t2.addChild(e2, n2)); + } + function K(t2, e2, i2) { + const n2 = this.options.processEntities; + if (!n2 || !n2.enabled) return t2; + if (n2.allowedTags) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!(Array.isArray(n2.allowedTags) ? n2.allowedTags.includes(e2) : n2.allowedTags(e2, s2))) return t2; + } + if (n2.tagFilter) { + const s2 = this.options.jPath ? i2.toString() : i2; + if (!n2.tagFilter(e2, s2)) return t2; + } + for (const e3 of Object.keys(this.docTypeEntities)) { + const i3 = this.docTypeEntities[e3], s2 = t2.match(i3.regx); if (s2) { - if (this.entityExpansionCount += s2.length, i2.maxTotalExpansions && this.entityExpansionCount > i2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i2.maxTotalExpansions}`); + if (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); const e4 = t2.length; - if (t2 = t2.replace(n3.regx, n3.val), i2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > i2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i2.maxExpandedLength}`); + if (t2 = t2.replace(i3.regx, i3.val), n2.maxExpandedLength && (this.currentExpandedLength += t2.length - e4, this.currentExpandedLength > n2.maxExpandedLength)) throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${n2.maxExpandedLength}`); } } - if (-1 === t2.indexOf("&")) return t2; - for (let e3 in this.lastEntities) { - const n3 = this.lastEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + for (const e3 of Object.keys(this.lastEntities)) { + const i3 = this.lastEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } if (-1 === t2.indexOf("&")) return t2; - if (this.options.htmlEntities) for (let e3 in this.htmlEntities) { - const n3 = this.htmlEntities[e3]; - t2 = t2.replace(n3.regex, n3.val); + if (this.options.htmlEntities) for (const e3 of Object.keys(this.htmlEntities)) { + const i3 = this.htmlEntities[e3], s2 = t2.match(i3.regex); + if (s2 && (this.entityExpansionCount += s2.length, n2.maxTotalExpansions && this.entityExpansionCount > n2.maxTotalExpansions)) throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${n2.maxTotalExpansions}`); + t2 = t2.replace(i3.regex, i3.val); } return t2.replace(this.ampEntity.regex, this.ampEntity.val); - }; - function G(t2, e2, n2, i2) { - return t2 && (void 0 === i2 && (i2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, n2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, i2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; } - function X(t2, e2, n2, i2) { - return !(!e2 || !e2.has(i2)) || !(!t2 || !t2.has(n2)); + function Q(t2, e2, i2, n2) { + return t2 && (void 0 === n2 && (n2 = 0 === e2.child.length), void 0 !== (t2 = this.parseTextData(t2, e2.tagname, i2, false, !!e2[":@"] && 0 !== Object.keys(e2[":@"]).length, n2)) && "" !== t2 && e2.add(this.options.textNodeName, t2), t2 = ""), t2; + } + function H(t2, e2) { + if (!t2 || 0 === t2.length) return false; + for (let i2 = 0; i2 < t2.length; i2++) if (e2.matches(t2[i2])) return true; + return false; } - function z(t2, e2, n2, i2) { - const s2 = t2.indexOf(e2, n2); - if (-1 === s2) throw new Error(i2); + function tt(t2, e2, i2, n2) { + const s2 = t2.indexOf(e2, i2); + if (-1 === s2) throw new Error(n2); return s2 + e2.length - 1; } - function W(t2, e2, n2, i2 = ">") { - const s2 = (function(t3, e3, n3 = ">") { - let i3, s3 = ""; + function et(t2, e2, i2, n2 = ">") { + const s2 = (function(t3, e3, i3 = ">") { + let n3, s3 = ""; for (let r3 = e3; r3 < t3.length; r3++) { let e4 = t3[r3]; - if (i3) e4 === i3 && (i3 = ""); - else if ('"' === e4 || "'" === e4) i3 = e4; - else if (e4 === n3[0]) { - if (!n3[1]) return { data: s3, index: r3 }; - if (t3[r3 + 1] === n3[1]) return { data: s3, index: r3 }; + if (n3) e4 === n3 && (n3 = ""); + else if ('"' === e4 || "'" === e4) n3 = e4; + else if (e4 === i3[0]) { + if (!i3[1]) return { data: s3, index: r3 }; + if (t3[r3 + 1] === i3[1]) return { data: s3, index: r3 }; } else " " === e4 && (e4 = " "); s3 += e4; } - })(t2, e2 + 1, i2); + })(t2, e2 + 1, n2); if (!s2) return; let r2 = s2.data; const o2 = s2.index, a2 = r2.search(/\s/); - let l2 = r2, u2 = true; - -1 !== a2 && (l2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); - const d2 = l2; - if (n2) { - const t3 = l2.indexOf(":"); - -1 !== t3 && (l2 = l2.substr(t3 + 1), u2 = l2 !== s2.data.substr(t3 + 1)); + let h2 = r2, l2 = true; + -1 !== a2 && (h2 = r2.substring(0, a2), r2 = r2.substring(a2 + 1).trimStart()); + const p2 = h2; + if (i2) { + const t3 = h2.indexOf(":"); + -1 !== t3 && (h2 = h2.substr(t3 + 1), l2 = h2 !== s2.data.substr(t3 + 1)); } - return { tagName: l2, tagExp: r2, closeIndex: o2, attrExpPresent: u2, rawTagName: d2 }; + return { tagName: h2, tagExp: r2, closeIndex: o2, attrExpPresent: l2, rawTagName: p2 }; } - function q(t2, e2, n2) { - const i2 = n2; + function it(t2, e2, i2) { + const n2 = i2; let s2 = 1; - for (; n2 < t2.length; n2++) if ("<" === t2[n2]) if ("/" === t2[n2 + 1]) { - const r2 = z(t2, ">", n2, `${e2} is not closed`); - if (t2.substring(n2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(i2, n2), i: r2 }; - n2 = r2; - } else if ("?" === t2[n2 + 1]) n2 = z(t2, "?>", n2 + 1, "StopNode is not closed."); - else if ("!--" === t2.substr(n2 + 1, 3)) n2 = z(t2, "-->", n2 + 3, "StopNode is not closed."); - else if ("![" === t2.substr(n2 + 1, 2)) n2 = z(t2, "]]>", n2, "StopNode is not closed.") - 2; + for (; i2 < t2.length; i2++) if ("<" === t2[i2]) if ("/" === t2[i2 + 1]) { + const r2 = tt(t2, ">", i2, `${e2} is not closed`); + if (t2.substring(i2 + 2, r2).trim() === e2 && (s2--, 0 === s2)) return { tagContent: t2.substring(n2, i2), i: r2 }; + i2 = r2; + } else if ("?" === t2[i2 + 1]) i2 = tt(t2, "?>", i2 + 1, "StopNode is not closed."); + else if ("!--" === t2.substr(i2 + 1, 3)) i2 = tt(t2, "-->", i2 + 3, "StopNode is not closed."); + else if ("![" === t2.substr(i2 + 1, 2)) i2 = tt(t2, "]]>", i2, "StopNode is not closed.") - 2; else { - const i3 = W(t2, n2, ">"); - i3 && ((i3 && i3.tagName) === e2 && "/" !== i3.tagExp[i3.tagExp.length - 1] && s2++, n2 = i3.closeIndex); + const n3 = et(t2, i2, ">"); + n3 && ((n3 && n3.tagName) === e2 && "/" !== n3.tagExp[n3.tagExp.length - 1] && s2++, i2 = n3.closeIndex); } } - function Z(t2, e2, n2) { + function nt(t2, e2, i2) { if (e2 && "string" == typeof t2) { const e3 = t2.trim(); return "true" === e3 || "false" !== e3 && (function(t3, e4 = {}) { - if (e4 = Object.assign({}, D, e4), !t3 || "string" != typeof t3) return t3; - let n3 = t3.trim(); - if (void 0 !== e4.skipLike && e4.skipLike.test(n3)) return t3; + if (e4 = Object.assign({}, F, e4), !t3 || "string" != typeof t3) return t3; + let i3 = t3.trim(); + if (void 0 !== e4.skipLike && e4.skipLike.test(i3)) return t3; if ("0" === t3) return 0; - if (e4.hex && $.test(n3)) return (function(t4) { + if (e4.hex && V.test(i3)) return (function(t4) { if (parseInt) return parseInt(t4, 16); if (Number.parseInt) return Number.parseInt(t4, 16); if (window && window.parseInt) return window.parseInt(t4, 16); throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); - })(n3); - if (n3.includes("e") || n3.includes("E")) return (function(t4, e5, n4) { - if (!n4.eNotation) return t4; - const i3 = e5.match(j); - if (i3) { - let s2 = i3[1] || ""; - const r2 = -1 === i3[3].indexOf("e") ? "E" : "e", o2 = i3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; - return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !i3[3].startsWith(`.${r2}`) && i3[3][0] !== r2 ? n4.leadingZeros && !a2 ? (e5 = (i3[1] || "") + i3[3], Number(e5)) : t4 : Number(e5); + })(i3); + if (i3.includes("e") || i3.includes("E")) return (function(t4, e5, i4) { + if (!i4.eNotation) return t4; + const n3 = e5.match(L); + if (n3) { + let s2 = n3[1] || ""; + const r2 = -1 === n3[3].indexOf("e") ? "E" : "e", o2 = n3[2], a2 = s2 ? t4[o2.length + 1] === r2 : t4[o2.length] === r2; + return o2.length > 1 && a2 ? t4 : 1 !== o2.length || !n3[3].startsWith(`.${r2}`) && n3[3][0] !== r2 ? i4.leadingZeros && !a2 ? (e5 = (n3[1] || "") + n3[3], Number(e5)) : t4 : Number(e5); } return t4; - })(t3, n3, e4); + })(t3, i3, e4); { - const s2 = V.exec(n3); + const s2 = k.exec(i3); if (s2) { const r2 = s2[1] || "", o2 = s2[2]; - let a2 = (i2 = s2[3]) && -1 !== i2.indexOf(".") ? ("." === (i2 = i2.replace(/0+$/, "")) ? i2 = "0" : "." === i2[0] ? i2 = "0" + i2 : "." === i2[i2.length - 1] && (i2 = i2.substring(0, i2.length - 1)), i2) : i2; - const l2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; - if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !l2)) return t3; + let a2 = (n2 = s2[3]) && -1 !== n2.indexOf(".") ? ("." === (n2 = n2.replace(/0+$/, "")) ? n2 = "0" : "." === n2[0] ? n2 = "0" + n2 : "." === n2[n2.length - 1] && (n2 = n2.substring(0, n2.length - 1)), n2) : n2; + const h2 = r2 ? "." === t3[o2.length + 1] : "." === t3[o2.length]; + if (!e4.leadingZeros && (o2.length > 1 || 1 === o2.length && !h2)) return t3; { - const i3 = Number(n3), s3 = String(i3); - if (0 === i3) return i3; - if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? i3 : t3; - if (-1 !== n3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? i3 : t3; - let l3 = o2 ? a2 : n3; - return o2 ? l3 === s3 || r2 + l3 === s3 ? i3 : t3 : l3 === s3 || l3 === r2 + s3 ? i3 : t3; + const n3 = Number(i3), s3 = String(n3); + if (0 === n3) return n3; + if (-1 !== s3.search(/[eE]/)) return e4.eNotation ? n3 : t3; + if (-1 !== i3.indexOf(".")) return "0" === s3 || s3 === a2 || s3 === `${r2}${a2}` ? n3 : t3; + let h3 = o2 ? a2 : i3; + return o2 ? h3 === s3 || r2 + h3 === s3 ? n3 : t3 : h3 === s3 || h3 === r2 + s3 ? n3 : t3; } } return t3; } - var i2; - })(t2, n2); + var n2; + })(t2, i2); } return void 0 !== t2 ? t2 : ""; } - function K(t2, e2, n2) { - const i2 = Number.parseInt(t2, e2); - return i2 >= 0 && i2 <= 1114111 ? String.fromCodePoint(i2) : n2 + t2 + ";"; + function st(t2, e2, i2) { + const n2 = Number.parseInt(t2, e2); + return n2 >= 0 && n2 <= 1114111 ? String.fromCodePoint(n2) : i2 + t2 + ";"; + } + function rt(t2, e2, i2, n2) { + if (t2) { + const n3 = t2(e2); + i2 === e2 && (i2 = n3), e2 = n3; + } + return { tagName: e2 = ot(e2, n2), tagExp: i2 }; } - const Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + function ot(t2, e2) { + if (a.includes(t2)) throw new Error(`[SECURITY] Invalid name: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); + return o.includes(t2) ? e2.onDangerousProperty(t2) : t2; } - function H(t2, e2, n2) { - let i2; + const at = $.getMetaDataSymbol(); + function ht(t2, e2) { + if (!t2 || "object" != typeof t2) return {}; + if (!e2) return t2; + const i2 = {}; + for (const n2 in t2) n2.startsWith(e2) ? i2[n2.substring(e2.length)] = t2[n2] : i2[n2] = t2[n2]; + return i2; + } + function lt(t2, e2, i2) { + return pt(t2, e2, i2); + } + function pt(t2, e2, i2) { + let n2; const s2 = {}; for (let r2 = 0; r2 < t2.length; r2++) { - const o2 = t2[r2], a2 = tt(o2); - let l2 = ""; - if (l2 = void 0 === n2 ? a2 : n2 + "." + a2, a2 === e2.textNodeName) void 0 === i2 ? i2 = o2[a2] : i2 += "" + o2[a2]; + const o2 = t2[r2], a2 = ut(o2); + if (void 0 !== a2 && a2 !== e2.textNodeName) { + const t3 = ht(o2[":@"] || {}, e2.attributeNamePrefix); + i2.push(a2, t3); + } + if (a2 === e2.textNodeName) void 0 === n2 ? n2 = o2[a2] : n2 += "" + o2[a2]; else { if (void 0 === a2) continue; if (o2[a2]) { - let t3 = H(o2[a2], e2, l2); - const n3 = nt(t3, e2); - o2[":@"] ? et(t3, o2[":@"], l2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[Q] && "object" == typeof t3 && null !== t3 && (t3[Q] = o2[Q]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2) ? (Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3)) : e2.isArray(a2, l2, n3) ? s2[a2] = [t3] : s2[a2] = t3; + let t3 = pt(o2[a2], e2, i2); + const n3 = dt(t3, e2); + if (o2[":@"] ? ct(t3, o2[":@"], i2, e2) : 1 !== Object.keys(t3).length || void 0 === t3[e2.textNodeName] || e2.alwaysCreateTextNode ? 0 === Object.keys(t3).length && (e2.alwaysCreateTextNode ? t3[e2.textNodeName] = "" : t3 = "") : t3 = t3[e2.textNodeName], void 0 !== o2[at] && "object" == typeof t3 && null !== t3 && (t3[at] = o2[at]), void 0 !== s2[a2] && Object.prototype.hasOwnProperty.call(s2, a2)) Array.isArray(s2[a2]) || (s2[a2] = [s2[a2]]), s2[a2].push(t3); + else { + const r3 = e2.jPath ? i2.toString() : i2; + e2.isArray(a2, r3, n3) ? s2[a2] = [t3] : s2[a2] = t3; + } + void 0 !== a2 && a2 !== e2.textNodeName && i2.pop(); } } } - return "string" == typeof i2 ? i2.length > 0 && (s2[e2.textNodeName] = i2) : void 0 !== i2 && (s2[e2.textNodeName] = i2), s2; + return "string" == typeof n2 ? n2.length > 0 && (s2[e2.textNodeName] = n2) : void 0 !== n2 && (s2[e2.textNodeName] = n2), s2; } - function tt(t2) { + function ut(t2) { const e2 = Object.keys(t2); for (let t3 = 0; t3 < e2.length; t3++) { - const n2 = e2[t3]; - if (":@" !== n2) return n2; + const i2 = e2[t3]; + if (":@" !== i2) return i2; } } - function et(t2, e2, n2, i2) { + function ct(t2, e2, i2, n2) { if (e2) { const s2 = Object.keys(e2), r2 = s2.length; for (let o2 = 0; o2 < r2; o2++) { - const r3 = s2[o2]; - i2.isArray(r3, n2 + "." + r3, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; + const r3 = s2[o2], a2 = r3.startsWith(n2.attributeNamePrefix) ? r3.substring(n2.attributeNamePrefix.length) : r3, h2 = n2.jPath ? i2.toString() + "." + a2 : i2; + n2.isArray(r3, h2, true, true) ? t2[r3] = [e2[r3]] : t2[r3] = e2[r3]; } } } - function nt(t2, e2) { - const { textNodeName: n2 } = e2, i2 = Object.keys(t2).length; - return 0 === i2 || !(1 !== i2 || !t2[n2] && "boolean" != typeof t2[n2] && 0 !== t2[n2]); + function dt(t2, e2) { + const { textNodeName: i2 } = e2, n2 = Object.keys(t2).length; + return 0 === n2 || !(1 !== n2 || !t2[i2] && "boolean" != typeof t2[i2] && 0 !== t2[i2]); } - class it { + class ft { constructor(t2) { - this.externalEntities = {}, this.options = v(t2); + this.externalEntities = {}, this.options = C(t2); } parse(t2, e2) { if ("string" != typeof t2 && t2.toString) t2 = t2.toString(); else if ("string" != typeof t2) throw new Error("XML data is accepted in String or Bytes[] form."); if (e2) { true === e2 && (e2 = {}); - const n3 = a(t2, e2); - if (true !== n3) throw Error(`${n3.err.msg}:${n3.err.line}:${n3.err.col}`); + const i3 = l(t2, e2); + if (true !== i3) throw Error(`${i3.err.msg}:${i3.err.line}:${i3.err.col}`); } - const n2 = new L(this.options); - n2.addExternalEntities(this.externalEntities); - const i2 = n2.parseXml(t2); - return this.options.preserveOrder || void 0 === i2 ? i2 : J(i2, this.options); + const i2 = new B(this.options); + i2.addExternalEntities(this.externalEntities); + const n2 = i2.parseXml(t2); + return this.options.preserveOrder || void 0 === n2 ? n2 : lt(n2, this.options, i2.matcher); } addEntity(t2, e2) { if (-1 !== e2.indexOf("&")) throw new Error("Entity value can't have '&'"); @@ -61233,172 +61484,305 @@ var require_fxp = __commonJS({ this.externalEntities[t2] = e2; } static getMetaDataSymbol() { - return I.getMetaDataSymbol(); + return $.getMetaDataSymbol(); } } - function st(t2, e2) { - let n2 = ""; - return e2.format && e2.indentBy.length > 0 && (n2 = "\n"), rt(t2, e2, "", n2); + function gt(t2, e2) { + let i2 = ""; + e2.format && e2.indentBy.length > 0 && (i2 = "\n"); + const n2 = []; + if (e2.stopNodes && Array.isArray(e2.stopNodes)) for (let t3 = 0; t3 < e2.stopNodes.length; t3++) { + const i3 = e2.stopNodes[t3]; + "string" == typeof i3 ? n2.push(new G(i3)) : i3 instanceof G && n2.push(i3); + } + return mt(t2, e2, i2, new M(), n2); } - function rt(t2, e2, n2, i2) { - let s2 = "", r2 = false; + function mt(t2, e2, i2, n2, s2) { + let r2 = "", o2 = false; + if (e2.maxNestedTags && n2.getDepth() > e2.maxNestedTags) throw new Error("Maximum nested tags exceeded"); if (!Array.isArray(t2)) { if (null != t2) { - let n3 = t2.toString(); - return n3 = ut(n3, e2), n3; + let i3 = t2.toString(); + return i3 = vt(i3, e2), i3; } return ""; } - for (let o2 = 0; o2 < t2.length; o2++) { - const a2 = t2[o2], l2 = ot(a2); + for (let a2 = 0; a2 < t2.length; a2++) { + const h2 = t2[a2], l2 = Et(h2); if (void 0 === l2) continue; - let u2 = ""; - if (u2 = 0 === n2.length ? l2 : `${n2}.${l2}`, l2 === e2.textNodeName) { - let t3 = a2[l2]; - lt(u2, e2) || (t3 = e2.tagValueProcessor(l2, t3), t3 = ut(t3, e2)), r2 && (s2 += i2), s2 += t3, r2 = false; + const p2 = xt(h2[":@"], e2); + n2.push(l2, p2); + const u2 = wt(n2, s2); + if (l2 === e2.textNodeName) { + let t3 = h2[l2]; + u2 || (t3 = e2.tagValueProcessor(l2, t3), t3 = vt(t3, e2)), o2 && (r2 += i2), r2 += t3, o2 = false, n2.pop(); continue; } if (l2 === e2.cdataPropName) { - r2 && (s2 += i2), s2 += ``, r2 = false; + o2 && (r2 += i2), r2 += ``, o2 = false, n2.pop(); continue; } if (l2 === e2.commentPropName) { - s2 += i2 + ``, r2 = true; + r2 += i2 + ``, o2 = true, n2.pop(); continue; } if ("?" === l2[0]) { - const t3 = at(a2[":@"], e2), n3 = "?xml" === l2 ? "" : i2; - let o3 = a2[l2][0][e2.textNodeName]; - o3 = 0 !== o3.length ? " " + o3 : "", s2 += n3 + `<${l2}${o3}${t3}?>`, r2 = true; + const t3 = yt(h2[":@"], e2, u2), s3 = "?xml" === l2 ? "" : i2; + let a3 = h2[l2][0][e2.textNodeName]; + a3 = 0 !== a3.length ? " " + a3 : "", r2 += s3 + `<${l2}${a3}${t3}?>`, o2 = true, n2.pop(); continue; } - let d2 = i2; - "" !== d2 && (d2 += e2.indentBy); - const h2 = i2 + `<${l2}${at(a2[":@"], e2)}`, p2 = rt(a2[l2], e2, u2, d2); - -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? s2 += h2 + ">" : s2 += h2 + "/>" : p2 && 0 !== p2.length || !e2.suppressEmptyNode ? p2 && p2.endsWith(">") ? s2 += h2 + `>${p2}${i2}` : (s2 += h2 + ">", p2 && "" !== i2 && (p2.includes("/>") || p2.includes("`) : s2 += h2 + "/>", r2 = true; + let c2 = i2; + "" !== c2 && (c2 += e2.indentBy); + const d2 = i2 + `<${l2}${yt(h2[":@"], e2, u2)}`; + let f2; + f2 = u2 ? Nt(h2[l2], e2) : mt(h2[l2], e2, c2, n2, s2), -1 !== e2.unpairedTags.indexOf(l2) ? e2.suppressUnpairedNode ? r2 += d2 + ">" : r2 += d2 + "/>" : f2 && 0 !== f2.length || !e2.suppressEmptyNode ? f2 && f2.endsWith(">") ? r2 += d2 + `>${f2}${i2}` : (r2 += d2 + ">", f2 && "" !== i2 && (f2.includes("/>") || f2.includes("`) : r2 += d2 + "/>", o2 = true, n2.pop(); + } + return r2; + } + function xt(t2, e2) { + if (!t2 || e2.ignoreAttributes) return null; + const i2 = {}; + let n2 = false; + for (let s2 in t2) Object.prototype.hasOwnProperty.call(t2, s2) && (i2[s2.startsWith(e2.attributeNamePrefix) ? s2.substr(e2.attributeNamePrefix.length) : s2] = t2[s2], n2 = true); + return n2 ? i2 : null; + } + function Nt(t2, e2) { + if (!Array.isArray(t2)) return null != t2 ? t2.toString() : ""; + let i2 = ""; + for (let n2 = 0; n2 < t2.length; n2++) { + const s2 = t2[n2], r2 = Et(s2); + if (r2 === e2.textNodeName) i2 += s2[r2]; + else if (r2 === e2.cdataPropName) i2 += s2[r2][0][e2.textNodeName]; + else if (r2 === e2.commentPropName) i2 += s2[r2][0][e2.textNodeName]; + else { + if (r2 && "?" === r2[0]) continue; + if (r2) { + const t3 = bt(s2[":@"], e2), n3 = Nt(s2[r2], e2); + n3 && 0 !== n3.length ? i2 += `<${r2}${t3}>${n3}` : i2 += `<${r2}${t3}/>`; + } + } } - return s2; + return i2; } - function ot(t2) { + function bt(t2, e2) { + let i2 = ""; + if (t2 && !e2.ignoreAttributes) for (let n2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, n2)) continue; + let s2 = t2[n2]; + true === s2 && e2.suppressBooleanAttributes ? i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}` : i2 += ` ${n2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + } + return i2; + } + function Et(t2) { const e2 = Object.keys(t2); - for (let n2 = 0; n2 < e2.length; n2++) { - const i2 = e2[n2]; - if (Object.prototype.hasOwnProperty.call(t2, i2) && ":@" !== i2) return i2; + for (let i2 = 0; i2 < e2.length; i2++) { + const n2 = e2[i2]; + if (Object.prototype.hasOwnProperty.call(t2, n2) && ":@" !== n2) return n2; } } - function at(t2, e2) { + function yt(t2, e2, i2) { let n2 = ""; - if (t2 && !e2.ignoreAttributes) for (let i2 in t2) { - if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; - let s2 = e2.attributeValueProcessor(i2, t2[i2]); - s2 = ut(s2, e2), true === s2 && e2.suppressBooleanAttributes ? n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${i2.substr(e2.attributeNamePrefix.length)}="${s2}"`; + if (t2 && !e2.ignoreAttributes) for (let s2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, s2)) continue; + let r2; + i2 ? r2 = t2[s2] : (r2 = e2.attributeValueProcessor(s2, t2[s2]), r2 = vt(r2, e2)), true === r2 && e2.suppressBooleanAttributes ? n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}` : n2 += ` ${s2.substr(e2.attributeNamePrefix.length)}="${r2}"`; } return n2; } - function lt(t2, e2) { - let n2 = (t2 = t2.substr(0, t2.length - e2.textNodeName.length - 1)).substr(t2.lastIndexOf(".") + 1); - for (let i2 in e2.stopNodes) if (e2.stopNodes[i2] === t2 || e2.stopNodes[i2] === "*." + n2) return true; + function wt(t2, e2) { + if (!e2 || 0 === e2.length) return false; + for (let i2 = 0; i2 < e2.length; i2++) if (t2.matches(e2[i2])) return true; return false; } - function ut(t2, e2) { - if (t2 && t2.length > 0 && e2.processEntities) for (let n2 = 0; n2 < e2.entities.length; n2++) { - const i2 = e2.entities[n2]; - t2 = t2.replace(i2.regex, i2.val); + function vt(t2, e2) { + if (t2 && t2.length > 0 && e2.processEntities) for (let i2 = 0; i2 < e2.entities.length; i2++) { + const n2 = e2.entities[i2]; + t2 = t2.replace(n2.regex, n2.val); } return t2; } - const dt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { + const Tt = { attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, cdataPropName: false, format: false, indentBy: " ", suppressEmptyNode: false, suppressUnpairedNode: true, suppressBooleanAttributes: true, tagValueProcessor: function(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; - }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false }; - function ht(t2) { + }, preserveOrder: false, commentPropName: false, unpairedTags: [], entities: [{ regex: new RegExp("&", "g"), val: "&" }, { regex: new RegExp(">", "g"), val: ">" }, { regex: new RegExp("<", "g"), val: "<" }, { regex: new RegExp("'", "g"), val: "'" }, { regex: new RegExp('"', "g"), val: """ }], processEntities: true, stopNodes: [], oneListGroup: false, maxNestedTags: 100, jPath: true }; + function Pt(t2) { + if (this.options = Object.assign({}, Tt, t2), this.options.stopNodes && Array.isArray(this.options.stopNodes) && (this.options.stopNodes = this.options.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), this.stopNodeExpressions = [], this.options.stopNodes && Array.isArray(this.options.stopNodes)) for (let t3 = 0; t3 < this.options.stopNodes.length; t3++) { + const e3 = this.options.stopNodes[t3]; + "string" == typeof e3 ? this.stopNodeExpressions.push(new G(e3)) : e3 instanceof G && this.stopNodeExpressions.push(e3); + } var e2; - this.options = Object.assign({}, dt, t2), true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { + true === this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() { return false; } : (this.ignoreAttributesFn = "function" == typeof (e2 = this.options.ignoreAttributes) ? e2 : Array.isArray(e2) ? (t3) => { - for (const n2 of e2) { - if ("string" == typeof n2 && t3 === n2) return true; - if (n2 instanceof RegExp && n2.test(t3)) return true; + for (const i2 of e2) { + if ("string" == typeof i2 && t3 === i2) return true; + if (i2 instanceof RegExp && i2.test(t3)) return true; } - } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = ft), this.processTextOrObjNode = pt, this.options.format ? (this.indentate = ct, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { + } : () => false, this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ct), this.processTextOrObjNode = St, this.options.format ? (this.indentate = At, this.tagEndChar = ">\n", this.newLine = "\n") : (this.indentate = function() { return ""; }, this.tagEndChar = ">", this.newLine = ""); } - function pt(t2, e2, n2, i2) { - const s2 = this.j2x(t2, n2 + 1, i2.concat(e2)); - return void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, s2.attrStr, n2) : this.buildObjectNode(s2.val, e2, s2.attrStr, n2); + function St(t2, e2, i2, n2) { + const s2 = this.extractAttributes(t2); + if (n2.push(e2, s2), this.checkStopNode(n2)) { + const s3 = this.buildRawContent(t2), r3 = this.buildAttributesForStopNode(t2); + return n2.pop(), this.buildObjectNode(s3, e2, r3, i2); + } + const r2 = this.j2x(t2, i2 + 1, n2); + return n2.pop(), void 0 !== t2[this.options.textNodeName] && 1 === Object.keys(t2).length ? this.buildTextValNode(t2[this.options.textNodeName], e2, r2.attrStr, i2, n2) : this.buildObjectNode(r2.val, e2, r2.attrStr, i2); } - function ct(t2) { + function At(t2) { return this.options.indentBy.repeat(t2); } - function ft(t2) { + function Ct(t2) { return !(!t2.startsWith(this.options.attributeNamePrefix) || t2 === this.options.textNodeName) && t2.substr(this.attrPrefixLen); } - ht.prototype.build = function(t2) { - return this.options.preserveOrder ? st(t2, this.options) : (Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }), this.j2x(t2, 0, []).val); - }, ht.prototype.j2x = function(t2, e2, n2) { - let i2 = "", s2 = ""; - const r2 = n2.join("."); - for (let o2 in t2) if (Object.prototype.hasOwnProperty.call(t2, o2)) if (void 0 === t2[o2]) this.isAttribute(o2) && (s2 += ""); - else if (null === t2[o2]) this.isAttribute(o2) || o2 === this.options.cdataPropName ? s2 += "" : "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if (t2[o2] instanceof Date) s2 += this.buildTextValNode(t2[o2], o2, "", e2); - else if ("object" != typeof t2[o2]) { - const n3 = this.isAttribute(o2); - if (n3 && !this.ignoreAttributesFn(n3, r2)) i2 += this.buildAttrPairStr(n3, "" + t2[o2]); - else if (!n3) if (o2 === this.options.textNodeName) { - let e3 = this.options.tagValueProcessor(o2, "" + t2[o2]); + Pt.prototype.build = function(t2) { + if (this.options.preserveOrder) return gt(t2, this.options); + { + Array.isArray(t2) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t2 = { [this.options.arrayNodeName]: t2 }); + const e2 = new M(); + return this.j2x(t2, 0, e2).val; + } + }, Pt.prototype.j2x = function(t2, e2, i2) { + let n2 = "", s2 = ""; + if (this.options.maxNestedTags && i2.getDepth() >= this.options.maxNestedTags) throw new Error("Maximum nested tags exceeded"); + const r2 = this.options.jPath ? i2.toString() : i2, o2 = this.checkStopNode(i2); + for (let a2 in t2) if (Object.prototype.hasOwnProperty.call(t2, a2)) if (void 0 === t2[a2]) this.isAttribute(a2) && (s2 += ""); + else if (null === t2[a2]) this.isAttribute(a2) || a2 === this.options.cdataPropName ? s2 += "" : "?" === a2[0] ? s2 += this.indentate(e2) + "<" + a2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + a2 + "/" + this.tagEndChar; + else if (t2[a2] instanceof Date) s2 += this.buildTextValNode(t2[a2], a2, "", e2, i2); + else if ("object" != typeof t2[a2]) { + const h2 = this.isAttribute(a2); + if (h2 && !this.ignoreAttributesFn(h2, r2)) n2 += this.buildAttrPairStr(h2, "" + t2[a2], o2); + else if (!h2) if (a2 === this.options.textNodeName) { + let e3 = this.options.tagValueProcessor(a2, "" + t2[a2]); s2 += this.replaceEntitiesValue(e3); - } else s2 += this.buildTextValNode(t2[o2], o2, "", e2); - } else if (Array.isArray(t2[o2])) { - const i3 = t2[o2].length; - let r3 = "", a2 = ""; - for (let l2 = 0; l2 < i3; l2++) { - const i4 = t2[o2][l2]; - if (void 0 === i4) ; - else if (null === i4) "?" === o2[0] ? s2 += this.indentate(e2) + "<" + o2 + "?" + this.tagEndChar : s2 += this.indentate(e2) + "<" + o2 + "/" + this.tagEndChar; - else if ("object" == typeof i4) if (this.options.oneListGroup) { - const t3 = this.j2x(i4, e2 + 1, n2.concat(o2)); - r3 += t3.val, this.options.attributesGroupName && i4.hasOwnProperty(this.options.attributesGroupName) && (a2 += t3.attrStr); - } else r3 += this.processTextOrObjNode(i4, o2, e2, n2); + } else { + i2.push(a2); + const n3 = this.checkStopNode(i2); + if (i2.pop(), n3) { + const i3 = "" + t2[a2]; + s2 += "" === i3 ? this.indentate(e2) + "<" + a2 + this.closeTag(a2) + this.tagEndChar : this.indentate(e2) + "<" + a2 + ">" + i3 + "" + t4 + "${t3}`; + else if ("object" == typeof t3 && null !== t3) { + const n3 = this.buildRawContent(t3), s2 = this.buildAttributesForStopNode(t3); + e2 += "" === n3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${n3}`; + } + } else if ("object" == typeof n2 && null !== n2) { + const t3 = this.buildRawContent(n2), s2 = this.buildAttributesForStopNode(n2); + e2 += "" === t3 ? `<${i2}${s2}/>` : `<${i2}${s2}>${t3}`; + } else e2 += `<${i2}>${n2}`; + } + return e2; + }, Pt.prototype.buildAttributesForStopNode = function(t2) { + if (!t2 || "object" != typeof t2) return ""; + let e2 = ""; + if (this.options.attributesGroupName && t2[this.options.attributesGroupName]) { + const i2 = t2[this.options.attributesGroupName]; + for (let t3 in i2) { + if (!Object.prototype.hasOwnProperty.call(i2, t3)) continue; + const n2 = t3.startsWith(this.options.attributeNamePrefix) ? t3.substring(this.options.attributeNamePrefix.length) : t3, s2 = i2[t3]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } else for (let i2 in t2) { + if (!Object.prototype.hasOwnProperty.call(t2, i2)) continue; + const n2 = this.isAttribute(i2); + if (n2) { + const s2 = t2[i2]; + true === s2 && this.options.suppressBooleanAttributes ? e2 += " " + n2 : e2 += " " + n2 + '="' + s2 + '"'; + } + } + return e2; + }, Pt.prototype.buildObjectNode = function(t2, e2, i2, n2) { + if ("" === t2) return "?" === e2[0] ? this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar : this.indentate(n2) + "<" + e2 + i2 + this.closeTag(e2) + this.tagEndChar; { let s2 = "` + this.newLine : this.indentate(i2) + "<" + e2 + n2 + r2 + this.tagEndChar + t2 + this.indentate(i2) + s2 : this.indentate(i2) + "<" + e2 + n2 + r2 + ">" + t2 + s2; + return "?" === e2[0] && (r2 = "?", s2 = ""), !i2 && "" !== i2 || -1 !== t2.indexOf("<") ? false !== this.options.commentPropName && e2 === this.options.commentPropName && 0 === r2.length ? this.indentate(n2) + `` + this.newLine : this.indentate(n2) + "<" + e2 + i2 + r2 + this.tagEndChar + t2 + this.indentate(n2) + s2 : this.indentate(n2) + "<" + e2 + i2 + r2 + ">" + t2 + s2; } - }, ht.prototype.closeTag = function(t2) { + }, Pt.prototype.closeTag = function(t2) { let e2 = ""; return -1 !== this.options.unpairedTags.indexOf(t2) ? this.options.suppressUnpairedNode || (e2 = "/") : e2 = this.options.suppressEmptyNode ? "/" : `>` + this.newLine; - if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(i2) + `` + this.newLine; - if ("?" === e2[0]) return this.indentate(i2) + "<" + e2 + n2 + "?" + this.tagEndChar; + }, Pt.prototype.checkStopNode = function(t2) { + if (!this.stopNodeExpressions || 0 === this.stopNodeExpressions.length) return false; + for (let e2 = 0; e2 < this.stopNodeExpressions.length; e2++) if (t2.matches(this.stopNodeExpressions[e2])) return true; + return false; + }, Pt.prototype.buildTextValNode = function(t2, e2, i2, n2, s2) { + if (false !== this.options.cdataPropName && e2 === this.options.cdataPropName) return this.indentate(n2) + `` + this.newLine; + if (false !== this.options.commentPropName && e2 === this.options.commentPropName) return this.indentate(n2) + `` + this.newLine; + if ("?" === e2[0]) return this.indentate(n2) + "<" + e2 + i2 + "?" + this.tagEndChar; { - let s2 = this.options.tagValueProcessor(e2, t2); - return s2 = this.replaceEntitiesValue(s2), "" === s2 ? this.indentate(i2) + "<" + e2 + n2 + this.closeTag(e2) + this.tagEndChar : this.indentate(i2) + "<" + e2 + n2 + ">" + s2 + "" + s3 + " 0 && this.options.processEntities) for (let e2 = 0; e2 < this.options.entities.length; e2++) { - const n2 = this.options.entities[e2]; - t2 = t2.replace(n2.regex, n2.val); + const i2 = this.options.entities[e2]; + t2 = t2.replace(i2.regex, i2.val); } return t2; }; - const gt = ht, xt = { validate: a }; + const Ot = Pt, $t = { validate: l }; module2.exports = e; })(); } @@ -90403,7 +90787,7 @@ var require_uploadUtils = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UploadProgress = void 0; exports2.uploadCacheArchiveSDK = uploadCacheArchiveSDK; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var storage_blob_1 = require_commonjs15(); var errors_1 = require_errors3(); var UploadProgress = class { @@ -90445,7 +90829,7 @@ var require_uploadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const uploadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core15.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); + core16.info(`Sent ${transferredBytes} of ${this.contentLength} (${percentage}%), ${uploadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -90502,14 +90886,14 @@ var require_uploadUtils = __commonJS({ }; try { uploadProgress.startDisplayTimer(); - core15.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); + core16.debug(`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`); const response = yield blockBlobClient.uploadFile(archivePath, uploadOptions); if (response._response.status >= 400) { throw new errors_1.InvalidResponseError(`uploadCacheArchiveSDK: upload failed with status code ${response._response.status}`); } return response; } catch (error3) { - core15.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); + core16.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error3.message}`); throw error3; } finally { uploadProgress.stopDisplayTimer(); @@ -90594,7 +90978,7 @@ var require_requestUtils = __commonJS({ exports2.retry = retry2; exports2.retryTypedResponse = retryTypedResponse; exports2.retryHttpClientResponse = retryHttpClientResponse; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var http_client_1 = require_lib(); var constants_1 = require_constants12(); function isSuccessStatusCode(statusCode) { @@ -90652,9 +91036,9 @@ var require_requestUtils = __commonJS({ isRetryable = isRetryableStatusCode(statusCode); errorMessage = `Cache service responded with ${statusCode}`; } - core15.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); + core16.debug(`${name} - Attempt ${attempt} of ${maxAttempts} failed with error: ${errorMessage}`); if (!isRetryable) { - core15.debug(`${name} - Error is not retryable`); + core16.debug(`${name} - Error is not retryable`); break; } yield sleep(delay2); @@ -90913,7 +91297,7 @@ var require_downloadUtils = __commonJS({ exports2.downloadCacheHttpClient = downloadCacheHttpClient; exports2.downloadCacheHttpClientConcurrent = downloadCacheHttpClientConcurrent; exports2.downloadCacheStorageSDK = downloadCacheStorageSDK; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var http_client_1 = require_lib(); var storage_blob_1 = require_commonjs15(); var buffer = __importStar2(require("buffer")); @@ -90951,7 +91335,7 @@ var require_downloadUtils = __commonJS({ this.segmentIndex = this.segmentIndex + 1; this.segmentSize = segmentSize; this.receivedBytes = 0; - core15.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); + core16.debug(`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`); } /** * Sets the number of bytes received for the current segment. @@ -90985,7 +91369,7 @@ var require_downloadUtils = __commonJS({ const percentage = (100 * (transferredBytes / this.contentLength)).toFixed(1); const elapsedTime = Date.now() - this.startTime; const downloadSpeed = (transferredBytes / (1024 * 1024) / (elapsedTime / 1e3)).toFixed(1); - core15.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); + core16.info(`Received ${transferredBytes} of ${this.contentLength} (${percentage}%), ${downloadSpeed} MBs/sec`); if (this.isDone()) { this.displayedComplete = true; } @@ -91035,7 +91419,7 @@ var require_downloadUtils = __commonJS({ })); downloadResponse.message.socket.setTimeout(constants_1.SocketTimeout, () => { downloadResponse.message.destroy(); - core15.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); + core16.debug(`Aborting download, socket timed out after ${constants_1.SocketTimeout} ms`); }); yield pipeResponseToStream(downloadResponse, writeStream); const contentLengthHeader = downloadResponse.message.headers["content-length"]; @@ -91046,7 +91430,7 @@ var require_downloadUtils = __commonJS({ throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`); } } else { - core15.debug("Unable to validate download, no Content-Length header"); + core16.debug("Unable to validate download, no Content-Length header"); } }); } @@ -91164,7 +91548,7 @@ var require_downloadUtils = __commonJS({ const properties = yield client.getProperties(); const contentLength = (_a = properties.contentLength) !== null && _a !== void 0 ? _a : -1; if (contentLength < 0) { - core15.debug("Unable to determine content length, downloading file with http-client..."); + core16.debug("Unable to determine content length, downloading file with http-client..."); yield downloadCacheHttpClient(archiveLocation, archivePath); } else { const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); @@ -91254,7 +91638,7 @@ var require_options = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUploadOptions = getUploadOptions; exports2.getDownloadOptions = getDownloadOptions; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); function getUploadOptions(copy) { const result = { useAzureSdk: false, @@ -91274,9 +91658,9 @@ var require_options = __commonJS({ } result.uploadConcurrency = !isNaN(Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) ? Math.min(32, Number(process.env["CACHE_UPLOAD_CONCURRENCY"])) : result.uploadConcurrency; result.uploadChunkSize = !isNaN(Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"])) ? Math.min(128 * 1024 * 1024, Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) * 1024 * 1024) : result.uploadChunkSize; - core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core15.debug(`Upload concurrency: ${result.uploadConcurrency}`); - core15.debug(`Upload chunk size: ${result.uploadChunkSize}`); + core16.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core16.debug(`Upload concurrency: ${result.uploadConcurrency}`); + core16.debug(`Upload chunk size: ${result.uploadChunkSize}`); return result; } function getDownloadOptions(copy) { @@ -91312,12 +91696,12 @@ var require_options = __commonJS({ if (segmentDownloadTimeoutMins && !isNaN(Number(segmentDownloadTimeoutMins)) && isFinite(Number(segmentDownloadTimeoutMins))) { result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1e3; } - core15.debug(`Use Azure SDK: ${result.useAzureSdk}`); - core15.debug(`Download concurrency: ${result.downloadConcurrency}`); - core15.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core15.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); - core15.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); - core15.debug(`Lookup only: ${result.lookupOnly}`); + core16.debug(`Use Azure SDK: ${result.useAzureSdk}`); + core16.debug(`Download concurrency: ${result.downloadConcurrency}`); + core16.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core16.debug(`Cache segment download timeout mins env var: ${process.env["SEGMENT_DOWNLOAD_TIMEOUT_MINS"]}`); + core16.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); + core16.debug(`Lookup only: ${result.lookupOnly}`); return result; } } @@ -91511,7 +91895,7 @@ var require_cacheHttpClient = __commonJS({ exports2.downloadCache = downloadCache; exports2.reserveCache = reserveCache; exports2.saveCache = saveCache4; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var http_client_1 = require_lib(); var auth_1 = require_auth(); var fs14 = __importStar2(require("fs")); @@ -91529,7 +91913,7 @@ var require_cacheHttpClient = __commonJS({ throw new Error("Cache Service Url not found, unable to restore cache."); } const url2 = `${baseUrl}_apis/artifactcache/${resource}`; - core15.debug(`Resource Url: ${url2}`); + core16.debug(`Resource Url: ${url2}`); return url2; } function createAcceptHeader(type2, apiVersion) { @@ -91557,7 +91941,7 @@ var require_cacheHttpClient = __commonJS({ return httpClient.getJson(getCacheApiUrl(resource)); })); if (response.statusCode === 204) { - if (core15.isDebug()) { + if (core16.isDebug()) { yield printCachesListForDiagnostics(keys[0], httpClient, version); } return null; @@ -91570,9 +91954,9 @@ var require_cacheHttpClient = __commonJS({ if (!cacheDownloadUrl) { throw new Error("Cache not found."); } - core15.setSecret(cacheDownloadUrl); - core15.debug(`Cache Result:`); - core15.debug(JSON.stringify(cacheResult)); + core16.setSecret(cacheDownloadUrl); + core16.debug(`Cache Result:`); + core16.debug(JSON.stringify(cacheResult)); return cacheResult; }); } @@ -91586,10 +91970,10 @@ var require_cacheHttpClient = __commonJS({ const cacheListResult = response.result; const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; if (totalCount && totalCount > 0) { - core15.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key + core16.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env["GITHUB_REF"]}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key Other caches with similar key:`); for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { - core15.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); + core16.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); } } } @@ -91632,7 +92016,7 @@ Other caches with similar key:`); } function uploadChunk(httpClient, resourceUrl, openStream, start, end) { return __awaiter2(this, void 0, void 0, function* () { - core15.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); + core16.debug(`Uploading chunk of size ${end - start + 1} bytes at offset ${start} with content range: ${getContentRange(start, end)}`); const additionalHeaders = { "Content-Type": "application/octet-stream", "Content-Range": getContentRange(start, end) @@ -91654,7 +92038,7 @@ Other caches with similar key:`); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const parallelUploads = [...new Array(concurrency).keys()]; - core15.debug("Awaiting all uploads"); + core16.debug("Awaiting all uploads"); let offset = 0; try { yield Promise.all(parallelUploads.map(() => __awaiter2(this, void 0, void 0, function* () { @@ -91697,16 +92081,16 @@ Other caches with similar key:`); yield (0, uploadUtils_1.uploadCacheArchiveSDK)(signedUploadURL, archivePath, options); } else { const httpClient = createHttpClient(); - core15.debug("Upload cache"); + core16.debug("Upload cache"); yield uploadFile(httpClient, cacheId, archivePath, options); - core15.debug("Commiting cache"); + core16.debug("Commiting cache"); const cacheSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); + core16.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`); const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize); if (!(0, requestUtils_1.isSuccessStatusCode)(commitCacheResponse.statusCode)) { throw new Error(`Cache service responded with ${commitCacheResponse.statusCode} during commit cache.`); } - core15.info("Cache saved successfully"); + core16.info("Cache saved successfully"); } }); } @@ -97189,7 +97573,7 @@ var require_cache5 = __commonJS({ exports2.isFeatureAvailable = isFeatureAvailable; exports2.restoreCache = restoreCache4; exports2.saveCache = saveCache4; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var path13 = __importStar2(require("path")); var utils = __importStar2(require_cacheUtils()); var cacheHttpClient = __importStar2(require_cacheHttpClient()); @@ -97248,7 +97632,7 @@ var require_cache5 = __commonJS({ function restoreCache4(paths_1, primaryKey_1, restoreKeys_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core15.debug(`Cache service version: ${cacheServiceVersion}`); + core16.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); switch (cacheServiceVersion) { case "v2": @@ -97263,8 +97647,8 @@ var require_cache5 = __commonJS({ return __awaiter2(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core15.debug("Resolved Keys:"); - core15.debug(JSON.stringify(keys)); + core16.debug("Resolved Keys:"); + core16.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -97282,19 +97666,19 @@ var require_cache5 = __commonJS({ return void 0; } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core15.info("Lookup only - skipping download"); + core16.info("Lookup only - skipping download"); return cacheEntry.cacheKey; } archivePath = path13.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core15.debug(`Archive Path: ${archivePath}`); + core16.debug(`Archive Path: ${archivePath}`); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); - if (core15.isDebug()) { + if (core16.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + core16.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core15.info("Cache restored successfully"); + core16.info("Cache restored successfully"); return cacheEntry.cacheKey; } catch (error3) { const typedError = error3; @@ -97302,16 +97686,16 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core15.error(`Failed to restore: ${error3.message}`); + core16.error(`Failed to restore: ${error3.message}`); } else { - core15.warning(`Failed to restore: ${error3.message}`); + core16.warning(`Failed to restore: ${error3.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core15.debug(`Failed to delete archive: ${error3}`); + core16.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -97322,8 +97706,8 @@ var require_cache5 = __commonJS({ options = Object.assign(Object.assign({}, options), { useAzureSdk: true }); restoreKeys = restoreKeys || []; const keys = [primaryKey, ...restoreKeys]; - core15.debug("Resolved Keys:"); - core15.debug(JSON.stringify(keys)); + core16.debug("Resolved Keys:"); + core16.debug(JSON.stringify(keys)); if (keys.length > 10) { throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`); } @@ -97341,30 +97725,30 @@ var require_cache5 = __commonJS({ }; const response = yield twirpClient.GetCacheEntryDownloadURL(request2); if (!response.ok) { - core15.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); + core16.debug(`Cache not found for version ${request2.version} of keys: ${keys.join(", ")}`); return void 0; } const isRestoreKeyMatch = request2.key !== response.matchedKey; if (isRestoreKeyMatch) { - core15.info(`Cache hit for restore-key: ${response.matchedKey}`); + core16.info(`Cache hit for restore-key: ${response.matchedKey}`); } else { - core15.info(`Cache hit for: ${response.matchedKey}`); + core16.info(`Cache hit for: ${response.matchedKey}`); } if (options === null || options === void 0 ? void 0 : options.lookupOnly) { - core15.info("Lookup only - skipping download"); + core16.info("Lookup only - skipping download"); return response.matchedKey; } archivePath = path13.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); - core15.debug(`Archive path: ${archivePath}`); - core15.debug(`Starting download of archive to: ${archivePath}`); + core16.debug(`Archive path: ${archivePath}`); + core16.debug(`Starting download of archive to: ${archivePath}`); yield cacheHttpClient.downloadCache(response.signedDownloadUrl, archivePath, options); const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); - if (core15.isDebug()) { + core16.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); + if (core16.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } yield (0, tar_1.extractTar)(archivePath, compressionMethod); - core15.info("Cache restored successfully"); + core16.info("Cache restored successfully"); return response.matchedKey; } catch (error3) { const typedError = error3; @@ -97372,9 +97756,9 @@ var require_cache5 = __commonJS({ throw error3; } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core15.error(`Failed to restore: ${error3.message}`); + core16.error(`Failed to restore: ${error3.message}`); } else { - core15.warning(`Failed to restore: ${error3.message}`); + core16.warning(`Failed to restore: ${error3.message}`); } } } finally { @@ -97383,7 +97767,7 @@ var require_cache5 = __commonJS({ yield utils.unlinkFile(archivePath); } } catch (error3) { - core15.debug(`Failed to delete archive: ${error3}`); + core16.debug(`Failed to delete archive: ${error3}`); } } return void 0; @@ -97392,7 +97776,7 @@ var require_cache5 = __commonJS({ function saveCache4(paths_1, key_1, options_1) { return __awaiter2(this, arguments, void 0, function* (paths, key, options, enableCrossOsArchive = false) { const cacheServiceVersion = (0, config_1.getCacheServiceVersion)(); - core15.debug(`Cache service version: ${cacheServiceVersion}`); + core16.debug(`Cache service version: ${cacheServiceVersion}`); checkPaths(paths); checkKey(key); switch (cacheServiceVersion) { @@ -97410,26 +97794,26 @@ var require_cache5 = __commonJS({ const compressionMethod = yield utils.getCompressionMethod(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core15.debug("Cache Paths:"); - core15.debug(`${JSON.stringify(cachePaths)}`); + core16.debug("Cache Paths:"); + core16.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path13.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core15.debug(`Archive Path: ${archivePath}`); + core16.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core15.isDebug()) { + if (core16.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const fileSizeLimit = 10 * 1024 * 1024 * 1024; const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.debug(`File Size: ${archiveFileSize}`); + core16.debug(`File Size: ${archiveFileSize}`); if (archiveFileSize > fileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } - core15.debug("Reserving Cache"); + core16.debug("Reserving Cache"); const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { compressionMethod, enableCrossOsArchive, @@ -97442,26 +97826,26 @@ var require_cache5 = __commonJS({ } else { throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`); } - core15.debug(`Saving Cache (ID: ${cacheId})`); + core16.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, "", options); } catch (error3) { const typedError = error3; if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core15.info(`Failed to save: ${typedError.message}`); + core16.info(`Failed to save: ${typedError.message}`); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core15.error(`Failed to save: ${typedError.message}`); + core16.error(`Failed to save: ${typedError.message}`); } else { - core15.warning(`Failed to save: ${typedError.message}`); + core16.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core15.debug(`Failed to delete archive: ${error3}`); + core16.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -97474,23 +97858,23 @@ var require_cache5 = __commonJS({ const twirpClient = cacheTwirpClient.internalCacheTwirpClient(); let cacheId = -1; const cachePaths = yield utils.resolvePaths(paths); - core15.debug("Cache Paths:"); - core15.debug(`${JSON.stringify(cachePaths)}`); + core16.debug("Cache Paths:"); + core16.debug(`${JSON.stringify(cachePaths)}`); if (cachePaths.length === 0) { throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`); } const archiveFolder = yield utils.createTempDirectory(); const archivePath = path13.join(archiveFolder, utils.getCacheFileName(compressionMethod)); - core15.debug(`Archive Path: ${archivePath}`); + core16.debug(`Archive Path: ${archivePath}`); try { yield (0, tar_1.createTar)(archiveFolder, cachePaths, compressionMethod); - if (core15.isDebug()) { + if (core16.isDebug()) { yield (0, tar_1.listTar)(archivePath, compressionMethod); } const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); - core15.debug(`File Size: ${archiveFileSize}`); + core16.debug(`File Size: ${archiveFileSize}`); options.archiveSizeBytes = archiveFileSize; - core15.debug("Reserving Cache"); + core16.debug("Reserving Cache"); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request2 = { key, @@ -97501,16 +97885,16 @@ var require_cache5 = __commonJS({ const response = yield twirpClient.CreateCacheEntry(request2); if (!response.ok) { if (response.message) { - core15.warning(`Cache reservation failed: ${response.message}`); + core16.warning(`Cache reservation failed: ${response.message}`); } throw new Error(response.message || "Response was not ok"); } signedUploadUrl = response.signedUploadUrl; } catch (error3) { - core15.debug(`Failed to reserve cache: ${error3}`); + core16.debug(`Failed to reserve cache: ${error3}`); throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); } - core15.debug(`Attempting to upload cache located at: ${archivePath}`); + core16.debug(`Attempting to upload cache located at: ${archivePath}`); yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options); const finalizeRequest = { key, @@ -97518,7 +97902,7 @@ var require_cache5 = __commonJS({ sizeBytes: `${archiveFileSize}` }; const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest); - core15.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); + core16.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`); if (!finalizeResponse.ok) { if (finalizeResponse.message) { throw new FinalizeCacheError(finalizeResponse.message); @@ -97531,21 +97915,21 @@ var require_cache5 = __commonJS({ if (typedError.name === ValidationError.name) { throw error3; } else if (typedError.name === ReserveCacheError.name) { - core15.info(`Failed to save: ${typedError.message}`); + core16.info(`Failed to save: ${typedError.message}`); } else if (typedError.name === FinalizeCacheError.name) { - core15.warning(typedError.message); + core16.warning(typedError.message); } else { if (typedError instanceof http_client_1.HttpClientError && typeof typedError.statusCode === "number" && typedError.statusCode >= 500) { - core15.error(`Failed to save: ${typedError.message}`); + core16.error(`Failed to save: ${typedError.message}`); } else { - core15.warning(`Failed to save: ${typedError.message}`); + core16.warning(`Failed to save: ${typedError.message}`); } } } finally { try { yield utils.unlinkFile(archivePath); } catch (error3) { - core15.debug(`Failed to delete archive: ${error3}`); + core16.debug(`Failed to delete archive: ${error3}`); } } return cacheId; @@ -99069,7 +99453,7 @@ var require_retry_helper = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RetryHelper = void 0; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var RetryHelper = class { constructor(maxAttempts, minSeconds, maxSeconds) { if (maxAttempts < 1) { @@ -99092,10 +99476,10 @@ var require_retry_helper = __commonJS({ if (isRetryable && !isRetryable(err)) { throw err; } - core15.info(err.message); + core16.info(err.message); } const seconds = this.getSleepAmount(); - core15.info(`Waiting ${seconds} seconds before trying again`); + core16.info(`Waiting ${seconds} seconds before trying again`); yield this.sleep(seconds); attempt++; } @@ -99198,7 +99582,7 @@ var require_tool_cache = __commonJS({ exports2.findFromManifest = findFromManifest; exports2.isExplicitVersion = isExplicitVersion; exports2.evaluateVersions = evaluateVersions; - var core15 = __importStar2(require_core()); + var core16 = __importStar2(require_core()); var io6 = __importStar2(require_io()); var crypto2 = __importStar2(require("crypto")); var fs14 = __importStar2(require("fs")); @@ -99227,8 +99611,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { dest = dest || path13.join(_getTempDirectory(), crypto2.randomUUID()); yield io6.mkdirP(path13.dirname(dest)); - core15.debug(`Downloading ${url2}`); - core15.debug(`Destination ${dest}`); + core16.debug(`Downloading ${url2}`); + core16.debug(`Destination ${dest}`); const maxAttempts = 3; const minSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS", 10); const maxSeconds = _getGlobal("TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS", 20); @@ -99254,7 +99638,7 @@ var require_tool_cache = __commonJS({ allowRetries: false }); if (auth2) { - core15.debug("set auth"); + core16.debug("set auth"); if (headers === void 0) { headers = {}; } @@ -99263,7 +99647,7 @@ var require_tool_cache = __commonJS({ const response = yield http.get(url2, headers); if (response.message.statusCode !== 200) { const err = new HTTPError2(response.message.statusCode); - core15.debug(`Failed to download from "${url2}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + core16.debug(`Failed to download from "${url2}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); throw err; } const pipeline = util.promisify(stream2.pipeline); @@ -99272,16 +99656,16 @@ var require_tool_cache = __commonJS({ let succeeded = false; try { yield pipeline(readStream, fs14.createWriteStream(dest)); - core15.debug("download complete"); + core16.debug("download complete"); succeeded = true; return dest; } finally { if (!succeeded) { - core15.debug("download failed"); + core16.debug("download failed"); try { yield io6.rmRF(dest); } catch (err) { - core15.debug(`Failed to delete '${dest}'. ${err.message}`); + core16.debug(`Failed to delete '${dest}'. ${err.message}`); } } } @@ -99296,7 +99680,7 @@ var require_tool_cache = __commonJS({ process.chdir(dest); if (_7zPath) { try { - const logLevel = core15.isDebug() ? "-bb1" : "-bb0"; + const logLevel = core16.isDebug() ? "-bb1" : "-bb0"; const args = [ "x", // eXtract files with full paths @@ -99349,7 +99733,7 @@ var require_tool_cache = __commonJS({ throw new Error("parameter 'file' is required"); } dest = yield _createExtractFolder(dest); - core15.debug("Checking tar --version"); + core16.debug("Checking tar --version"); let versionOutput = ""; yield (0, exec_1.exec)("tar --version", [], { ignoreReturnCode: true, @@ -99359,7 +99743,7 @@ var require_tool_cache = __commonJS({ stderr: (data) => versionOutput += data.toString() } }); - core15.debug(versionOutput.trim()); + core16.debug(versionOutput.trim()); const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR"); let args; if (flags instanceof Array) { @@ -99367,7 +99751,7 @@ var require_tool_cache = __commonJS({ } else { args = [flags]; } - if (core15.isDebug() && !flags.includes("v")) { + if (core16.isDebug() && !flags.includes("v")) { args.push("-v"); } let destArg = dest; @@ -99398,7 +99782,7 @@ var require_tool_cache = __commonJS({ args = [flags]; } args.push("-x", "-C", dest, "-f", file); - if (core15.isDebug()) { + if (core16.isDebug()) { args.push("-v"); } const xarPath = yield io6.which("xar", true); @@ -99441,7 +99825,7 @@ var require_tool_cache = __commonJS({ "-Command", pwshCommand ]; - core15.debug(`Using pwsh at path: ${pwshPath}`); + core16.debug(`Using pwsh at path: ${pwshPath}`); yield (0, exec_1.exec)(`"${pwshPath}"`, args); } else { const powershellCommand = [ @@ -99461,7 +99845,7 @@ var require_tool_cache = __commonJS({ powershellCommand ]; const powershellPath = yield io6.which("powershell", true); - core15.debug(`Using powershell at path: ${powershellPath}`); + core16.debug(`Using powershell at path: ${powershellPath}`); yield (0, exec_1.exec)(`"${powershellPath}"`, args); } }); @@ -99470,7 +99854,7 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { const unzipPath = yield io6.which("unzip", true); const args = [file]; - if (!core15.isDebug()) { + if (!core16.isDebug()) { args.unshift("-q"); } args.unshift("-o"); @@ -99481,8 +99865,8 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os3.arch(); - core15.debug(`Caching tool ${tool} ${version} ${arch2}`); - core15.debug(`source dir: ${sourceDir}`); + core16.debug(`Caching tool ${tool} ${version} ${arch2}`); + core16.debug(`source dir: ${sourceDir}`); if (!fs14.statSync(sourceDir).isDirectory()) { throw new Error("sourceDir is not a directory"); } @@ -99499,14 +99883,14 @@ var require_tool_cache = __commonJS({ return __awaiter2(this, void 0, void 0, function* () { version = semver9.clean(version) || version; arch2 = arch2 || os3.arch(); - core15.debug(`Caching tool ${tool} ${version} ${arch2}`); - core15.debug(`source file: ${sourceFile}`); + core16.debug(`Caching tool ${tool} ${version} ${arch2}`); + core16.debug(`source file: ${sourceFile}`); if (!fs14.statSync(sourceFile).isFile()) { throw new Error("sourceFile is not a file"); } const destFolder = yield _createToolPath(tool, version, arch2); const destPath = path13.join(destFolder, targetFile); - core15.debug(`destination file ${destPath}`); + core16.debug(`destination file ${destPath}`); yield io6.cp(sourceFile, destPath); _completeToolPath(tool, version, arch2); return destFolder; @@ -99529,12 +99913,12 @@ var require_tool_cache = __commonJS({ if (versionSpec) { versionSpec = semver9.clean(versionSpec) || ""; const cachePath = path13.join(_getCacheDirectory(), toolName, versionSpec, arch2); - core15.debug(`checking cache: ${cachePath}`); + core16.debug(`checking cache: ${cachePath}`); if (fs14.existsSync(cachePath) && fs14.existsSync(`${cachePath}.complete`)) { - core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); + core16.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); toolPath = cachePath; } else { - core15.debug("not found"); + core16.debug("not found"); } } return toolPath; @@ -99563,7 +99947,7 @@ var require_tool_cache = __commonJS({ const http = new httpm.HttpClient("tool-cache"); const headers = {}; if (auth2) { - core15.debug("set auth"); + core16.debug("set auth"); headers.authorization = auth2; } const response = yield http.getJson(treeUrl, headers); @@ -99584,7 +99968,7 @@ var require_tool_cache = __commonJS({ try { releases = JSON.parse(versionsRaw); } catch (_a) { - core15.debug("Invalid json"); + core16.debug("Invalid json"); } } return releases; @@ -99608,7 +99992,7 @@ var require_tool_cache = __commonJS({ function _createToolPath(tool, version, arch2) { return __awaiter2(this, void 0, void 0, function* () { const folderPath = path13.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); - core15.debug(`destination ${folderPath}`); + core16.debug(`destination ${folderPath}`); const markerPath = `${folderPath}.complete`; yield io6.rmRF(folderPath); yield io6.rmRF(markerPath); @@ -99620,18 +100004,18 @@ var require_tool_cache = __commonJS({ const folderPath = path13.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); const markerPath = `${folderPath}.complete`; fs14.writeFileSync(markerPath, ""); - core15.debug("finished caching tool"); + core16.debug("finished caching tool"); } function isExplicitVersion(versionSpec) { const c = semver9.clean(versionSpec) || ""; - core15.debug(`isExplicit: ${c}`); + core16.debug(`isExplicit: ${c}`); const valid3 = semver9.valid(c) != null; - core15.debug(`explicit? ${valid3}`); + core16.debug(`explicit? ${valid3}`); return valid3; } function evaluateVersions(versions, versionSpec) { let version = ""; - core15.debug(`evaluating ${versions.length} versions`); + core16.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { if (semver9.gt(a, b)) { return 1; @@ -99647,9 +100031,9 @@ var require_tool_cache = __commonJS({ } } if (version) { - core15.debug(`matched: ${version}`); + core16.debug(`matched: ${version}`); } else { - core15.debug("match not found"); + core16.debug("match not found"); } return version; } @@ -103121,7 +103505,7 @@ var require_sarif_schema_2_1_0 = __commonJS({ }); // src/upload-sarif-action.ts -var core14 = __toESM(require_core()); +var core15 = __toESM(require_core()); // src/actions-util.ts var fs2 = __toESM(require("fs")); @@ -106046,7 +106430,7 @@ function getTemporaryDirectory() { return value !== void 0 && value !== "" ? value : getRequiredEnvParam("RUNNER_TEMP"); } function getActionVersion() { - return "3.33.0"; + return "3.34.0"; } function getWorkflowEventName() { return getRequiredEnvParam("GITHUB_EVENT_NAME"); @@ -106518,8 +106902,8 @@ var path4 = __toESM(require("path")); var semver4 = __toESM(require_semver2()); // src/defaults.json -var bundleVersion = "codeql-bundle-v2.24.3"; -var cliVersion = "2.24.3"; +var bundleVersion = "codeql-bundle-v2.25.0"; +var cliVersion = "2.25.0"; // src/overlay/index.ts var fs3 = __toESM(require("fs")); @@ -106755,6 +107139,7 @@ function formatDuration(durationMs) { // src/overlay/index.ts var CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; +var CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; var CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; var CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; var CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; @@ -106905,6 +107290,11 @@ var featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + ["overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -106935,6 +107325,11 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY }, + ["overlay_analysis_cpp" /* OverlayAnalysisCpp */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP + }, ["overlay_analysis_csharp" /* OverlayAnalysisCsharp */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -106945,16 +107340,6 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO }, - ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: void 0 - }, - ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: void 0 - }, ["overlay_analysis_java" /* OverlayAnalysisJava */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -106970,15 +107355,31 @@ var featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON }, + ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + }, + // Other overlay-related feature flags + ["overlay_analysis_disable_trap_caching" /* OverlayAnalysisDisableTrapCaching */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: void 0 + }, ["overlay_analysis_resource_checks_v2" /* OverlayAnalysisResourceChecksV2 */]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: void 0 }, - ["overlay_analysis_ruby" /* OverlayAnalysisRuby */]: { + ["overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: void 0 + }, + ["overlay_analysis_status_save" /* OverlayAnalysisStatusSave */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: void 0 }, ["overlay_analysis_skip_resource_checks" /* OverlayAnalysisSkipResourceChecks */]: { defaultValue: false, @@ -107422,11 +107823,12 @@ function areAllRunsUnique(sarifLogs) { // src/status-report.ts var os = __toESM(require("os")); -var core9 = __toESM(require_core()); +var core10 = __toESM(require_core()); // src/config-utils.ts var fs7 = __toESM(require("fs")); var path7 = __toESM(require("path")); +var core9 = __toESM(require_core()); // src/config/db-config.ts var jsonschema = __toESM(require_lib2()); @@ -107543,6 +107945,7 @@ var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB = 14e3; var OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_BYTES = OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_V2_MB * 1e6; var OVERLAY_MINIMUM_MEMORY_MB = 5 * 1024; var OVERLAY_ANALYSIS_FEATURES = { + cpp: "overlay_analysis_cpp" /* OverlayAnalysisCpp */, csharp: "overlay_analysis_csharp" /* OverlayAnalysisCsharp */, go: "overlay_analysis_go" /* OverlayAnalysisGo */, java: "overlay_analysis_java" /* OverlayAnalysisJava */, @@ -107551,6 +107954,7 @@ var OVERLAY_ANALYSIS_FEATURES = { ruby: "overlay_analysis_ruby" /* OverlayAnalysisRuby */ }; var OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES = { + cpp: "overlay_analysis_code_scanning_cpp" /* OverlayAnalysisCodeScanningCpp */, csharp: "overlay_analysis_code_scanning_csharp" /* OverlayAnalysisCodeScanningCsharp */, go: "overlay_analysis_code_scanning_go" /* OverlayAnalysisCodeScanningGo */, java: "overlay_analysis_code_scanning_java" /* OverlayAnalysisCodeScanningJava */, @@ -107620,12 +108024,12 @@ function getActionsStatus(error3, otherFailureCause) { } function setJobStatusIfUnsuccessful(actionStatus) { if (actionStatus === "user-error") { - core9.exportVariable( + core10.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); } else if (actionStatus === "failure" || actionStatus === "aborted") { - core9.exportVariable( + core10.exportVariable( "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_FAILURE" /* FailureStatus */ ); @@ -107644,14 +108048,14 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi let workflowStartedAt = process.env["CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */]; if (workflowStartedAt === void 0) { workflowStartedAt = actionStartedAt.toISOString(); - core9.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); + core10.exportVariable("CODEQL_WORKFLOW_STARTED_AT" /* WORKFLOW_STARTED_AT */, workflowStartedAt); } const runnerOs = getRequiredEnvParam("RUNNER_OS"); const codeQlCliVersion = getCachedCodeQlVersion(); const actionRef = process.env["GITHUB_ACTION_REF"] || ""; const testingEnvironment = getTestingEnvironment(); if (testingEnvironment) { - core9.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); + core10.exportVariable("CODEQL_ACTION_TESTING_ENVIRONMENT" /* TESTING_ENVIRONMENT */, testingEnvironment); } const isSteadyStateDefaultSetupRun = process.env["CODE_SCANNING_IS_STEADY_STATE_DEFAULT_SETUP"] === "true"; const statusReport = { @@ -107734,9 +108138,9 @@ var INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the API endpo async function sendStatusReport(statusReport) { setJobStatusIfUnsuccessful(statusReport.status); const statusReportJSON = JSON.stringify(statusReport); - core9.debug(`Sending status report: ${statusReportJSON}`); + core10.debug(`Sending status report: ${statusReportJSON}`); if (isInTestMode()) { - core9.debug("In test mode. Status reports are not uploaded."); + core10.debug("In test mode. Status reports are not uploaded."); return; } const nwo = getRepositoryNwo(); @@ -107756,28 +108160,28 @@ async function sendStatusReport(statusReport) { switch (httpError.status) { case 403: if (getWorkflowEventName() === "push" && process.env["GITHUB_ACTOR"] === "dependabot[bot]") { - core9.warning( + core10.warning( `Workflows triggered by Dependabot on the "push" event run with read-only access. Uploading CodeQL results requires write access. To use CodeQL with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. See ${"https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push" /* SCANNING_ON_PUSH */} for more information on how to configure these events.` ); } else { - core9.warning( + core10.warning( `This run of the CodeQL Action does not have permission to access the CodeQL Action API endpoints. This could be because the Action is running on a pull request from a fork. If not, please ensure the workflow has at least the 'security-events: read' permission. Details: ${httpError.message}` ); } return; case 404: - core9.warning(httpError.message); + core10.warning(httpError.message); return; case 422: if (getRequiredEnvParam("GITHUB_SERVER_URL") !== GITHUB_DOTCOM_URL) { - core9.debug(INCOMPATIBLE_MSG); + core10.debug(INCOMPATIBLE_MSG); } else { - core9.debug(OUT_OF_DATE_MSG); + core10.debug(OUT_OF_DATE_MSG); } return; } } - core9.warning( + core10.warning( `An unexpected error occurred when sending a status report: ${getErrorMessage( e )}` @@ -107814,13 +108218,13 @@ var fs13 = __toESM(require("fs")); var path12 = __toESM(require("path")); var url = __toESM(require("url")); var import_zlib = __toESM(require("zlib")); -var core13 = __toESM(require_core()); +var core14 = __toESM(require_core()); var jsonschema2 = __toESM(require_lib2()); // src/codeql.ts var fs11 = __toESM(require("fs")); var path10 = __toESM(require("path")); -var core11 = __toESM(require_core()); +var core12 = __toESM(require_core()); var toolrunner3 = __toESM(require_toolrunner()); // src/cli-errors.ts @@ -108289,7 +108693,7 @@ var fs9 = __toESM(require("fs")); var os2 = __toESM(require("os")); var path8 = __toESM(require("path")); var import_perf_hooks = require("perf_hooks"); -var core10 = __toESM(require_core()); +var core11 = __toESM(require_core()); var import_http_client = __toESM(require_lib()); var toolcache2 = __toESM(require_tool_cache()); var import_follow_redirects = __toESM(require_follow_redirects()); @@ -108343,10 +108747,10 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat }; } } catch (e) { - core10.warning( + core11.warning( `Failed to download and extract CodeQL bundle using streaming with error: ${getErrorMessage(e)}` ); - core10.warning(`Falling back to downloading the bundle before extracting.`); + core11.warning(`Falling back to downloading the bundle before extracting.`); await cleanUpPath(dest, "CodeQL bundle", logger); } const toolsDownloadStart = import_perf_hooks.performance.now(); @@ -109028,7 +109432,6 @@ var CODEQL_NEXT_MINIMUM_VERSION = "2.17.6"; var GHES_VERSION_MOST_RECENTLY_DEPRECATED = "3.13"; var GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; var EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -var CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; async function setupCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, features, logger, checkVersion) { try { const { @@ -109372,17 +109775,13 @@ ${output}` }); }, async databaseCleanupCluster(config, cleanupLevel) { - const cacheCleanupFlag = await codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP - ) ? "--cache-cleanup" : "--mode"; for (const language of config.languages) { const databasePath = getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]) ]; await runCli(cmd, codeqlArgs); @@ -109531,12 +109930,12 @@ ${output}` ); } else if (checkVersion && process.env["CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */] !== "true" && !await codeQlVersionAtLeast(codeql, CODEQL_NEXT_MINIMUM_VERSION)) { const result = await codeql.getVersion(); - core11.warning( + core12.warning( `CodeQL CLI version ${result.version} was discontinued on ${GHES_MOST_RECENT_DEPRECATION_DATE} alongside GitHub Enterprise Server ${GHES_VERSION_MOST_RECENTLY_DEPRECATED} and will not be supported by the next minor release of the CodeQL Action. Please update to CodeQL CLI version ${CODEQL_NEXT_MINIMUM_VERSION} or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. Alternatively, if you want to continue using CodeQL CLI version ${result.version}, you can replace 'github/codeql-action/*@v${getActionVersion().split(".")[0]}' by 'github/codeql-action/*@v${getActionVersion()}' in your code scanning workflow to continue using this version of the CodeQL Action.` ); - core11.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); + core12.exportVariable("CODEQL_ACTION_SUPPRESS_DEPRECATED_SOON_WARNING" /* SUPPRESS_DEPRECATED_SOON_WARNING */, "true"); } return codeql; } @@ -110764,7 +111163,7 @@ async function addFingerprints(sarifLog, sourceRoot, logger) { } // src/init.ts -var core12 = __toESM(require_core()); +var core13 = __toESM(require_core()); var toolrunner4 = __toESM(require_toolrunner()); var github2 = __toESM(require_github()); var io5 = __toESM(require_io()); @@ -110837,7 +111236,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo logger.warning( `Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}` ); - core13.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); + core14.exportVariable("CODEQL_MERGE_SARIF_DEPRECATION_WARNING", "true"); } return combineSarifFiles(sarifFiles, logger); } @@ -110936,13 +111335,13 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) { if (httpError !== void 0) { switch (httpError.status) { case 403: - core13.warning(httpError.message || GENERIC_403_MSG); + core14.warning(httpError.message || GENERIC_403_MSG); break; case 404: - core13.warning(httpError.message || GENERIC_404_MSG); + core14.warning(httpError.message || GENERIC_404_MSG); break; default: - core13.warning(httpError.message); + core14.warning(httpError.message); break; } } @@ -111329,7 +111728,7 @@ function validateUniqueCategory(sarifLog, sentinelPrefix) { `Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per tool/category. The easiest fix is to specify a unique value for the \`category\` input. If .runs[].automationDetails.id is specified in the sarif file, that will take precedence over your configured \`category\`. Category: (${id ? id : "none"}) Tool: (${tool ? tool : "none"})` ); } - core13.exportVariable(sentinelEnvVar, sentinelEnvVar); + core14.exportVariable(sentinelEnvVar, sentinelEnvVar); } } function sanitize(str2) { @@ -111343,7 +111742,6 @@ function filterAlertsByDiffRange(logger, sarifLog) { if (sarifLog.runs === void 0) { return sarifLog; } - const checkoutPath = getRequiredInput("checkout_path"); for (const run2 of sarifLog.runs) { if (run2.results) { run2.results = run2.results.filter((result) => { @@ -111357,9 +111755,8 @@ function filterAlertsByDiffRange(logger, sarifLog) { if (!locationUri || locationStartLine === void 0) { return false; } - const locationPath = path12.join(checkoutPath, locationUri).replaceAll(path12.sep, "/"); return diffRanges.some( - (range) => range.path === locationPath && (range.startLine <= locationStartLine && range.endLine >= locationStartLine || range.startLine === 0 && range.endLine === 0) + (range) => range.path === locationUri && (range.startLine <= locationStartLine && range.endLine >= locationStartLine || range.startLine === 0 && range.endLine === 0) ); }); }); @@ -111466,11 +111863,11 @@ async function run(startedAt) { } const codeScanningResult = uploadResults["code-scanning" /* CodeScanning */]; if (codeScanningResult !== void 0) { - core14.setOutput("sarif-id", codeScanningResult.sarifID); + core15.setOutput("sarif-id", codeScanningResult.sarifID); } - core14.setOutput("sarif-ids", JSON.stringify(uploadResults)); + core15.setOutput("sarif-ids", JSON.stringify(uploadResults)); if (shouldSkipSarifUpload()) { - core14.debug( + core15.debug( "SARIF upload disabled by an environment variable. Waiting for processing is disabled." ); } else if (getRequiredInput("wait-for-processing") === "true") { @@ -111490,7 +111887,7 @@ async function run(startedAt) { } catch (unwrappedError) { const error3 = isThirdPartyAnalysis("upload-sarif" /* UploadSarif */) && unwrappedError instanceof InvalidSarifUploadError ? new ConfigurationError(unwrappedError.message) : wrapError(unwrappedError); const message = error3.message; - core14.setFailed(message); + core15.setFailed(message); const errorStatusReportBase = await createStatusReportBase( "upload-sarif" /* UploadSarif */, getActionsStatus(error3), @@ -111513,7 +111910,7 @@ async function runWrapper() { try { await run(startedAt); } catch (error3) { - core14.setFailed( + core15.setFailed( `codeql/upload-sarif action failed: ${getErrorMessage(error3)}` ); await sendUnhandledErrorStatusReport( diff --git a/package-lock.json b/package-lock.json index ab118df0e4..0f253eac79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codeql", - "version": "4.33.0", + "version": "4.34.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "codeql", - "version": "4.33.0", + "version": "4.34.0", "license": "MIT", "workspaces": [ "pr-checks" @@ -38,7 +38,7 @@ }, "devDependencies": { "@ava/typescript": "6.0.0", - "@eslint/compat": "^2.0.2", + "@eslint/compat": "^2.0.3", "@microsoft/eslint-formatter-sarif": "^3.1.0", "@octokit/types": "^16.0.0", "@types/archiver": "^7.0.0", @@ -62,7 +62,7 @@ "nock": "^14.0.11", "sinon": "^21.0.2", "typescript": "^5.9.3", - "typescript-eslint": "^8.56.1" + "typescript-eslint": "^8.57.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1364,13 +1364,13 @@ } }, "node_modules/@eslint/compat": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-2.0.2.tgz", - "integrity": "sha512-pR1DoD0h3HfF675QZx0xsyrsU8q70Z/plx7880NOhS02NuWLgBCOMDL787nUeQ7EWLkxv3bPQJaarjcPQb2Dwg==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-2.0.3.tgz", + "integrity": "sha512-SjIJhGigp8hmd1YGIBwh7Ovri7Kisl42GYFjrOyHhtfYGGoLW6teYi/5p8W50KSsawUPpuLOSmsq1bD0NGQLBw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/core": "^1.1.0" + "@eslint/core": "^1.1.1" }, "engines": { "node": "^20.19.0 || ^22.13.0 || >=24" @@ -1426,9 +1426,9 @@ } }, "node_modules/@eslint/core": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.1.0.tgz", - "integrity": "sha512-/nr9K9wkr3P1EzFTdFdMoLuo1PmIxjmwvPozwoSodjNBdefGujXQUF93u1DDZpEaTuDvMsIQddsd35BwtrW9Xw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-1.1.1.tgz", + "integrity": "sha512-QUPblTtE51/7/Zhfv8BDwO0qkkzQL7P/aWWbqcf4xWLEYn1oKjdO0gglQBB4GAsu7u6wjijbCmzsUTy6mnk6oQ==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -2547,17 +2547,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.56.1.tgz", - "integrity": "sha512-Jz9ZztpB37dNC+HU2HI28Bs9QXpzCz+y/twHOwhyrIRdbuVDxSytJNDl6z/aAKlaRIwC7y8wJdkBv7FxYGgi0A==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.57.0.tgz", + "integrity": "sha512-qeu4rTHR3/IaFORbD16gmjq9+rEs9fGKdX0kF6BKSfi+gCuG3RCKLlSBYzn/bGsY9Tj7KE/DAQStbp8AHJGHEQ==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.56.1", - "@typescript-eslint/type-utils": "8.56.1", - "@typescript-eslint/utils": "8.56.1", - "@typescript-eslint/visitor-keys": "8.56.1", + "@typescript-eslint/scope-manager": "8.57.0", + "@typescript-eslint/type-utils": "8.57.0", + "@typescript-eslint/utils": "8.57.0", + "@typescript-eslint/visitor-keys": "8.57.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.4.0" @@ -2570,7 +2570,7 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.56.1", + "@typescript-eslint/parser": "^8.57.0", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.0.0" } @@ -2586,16 +2586,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.56.1.tgz", - "integrity": "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.57.0.tgz", + "integrity": "sha512-XZzOmihLIr8AD1b9hL9ccNMzEMWt/dE2u7NyTY9jJG6YNiNthaD5XtUHVF2uCXZ15ng+z2hT3MVuxnUYhq6k1g==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.56.1", - "@typescript-eslint/types": "8.56.1", - "@typescript-eslint/typescript-estree": "8.56.1", - "@typescript-eslint/visitor-keys": "8.56.1", + "@typescript-eslint/scope-manager": "8.57.0", + "@typescript-eslint/types": "8.57.0", + "@typescript-eslint/typescript-estree": "8.57.0", + "@typescript-eslint/visitor-keys": "8.57.0", "debug": "^4.4.3" }, "engines": { @@ -2629,14 +2629,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.56.1.tgz", - "integrity": "sha512-TAdqQTzHNNvlVFfR+hu2PDJrURiwKsUvxFn1M0h95BB8ah5jejas08jUWG4dBA68jDMI988IvtfdAI53JzEHOQ==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.57.0.tgz", + "integrity": "sha512-pR+dK0BlxCLxtWfaKQWtYr7MhKmzqZxuii+ZjuFlZlIGRZm22HnXFqa2eY+90MUz8/i80YJmzFGDUsi8dMOV5w==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.56.1", - "@typescript-eslint/types": "^8.56.1", + "@typescript-eslint/tsconfig-utils": "^8.57.0", + "@typescript-eslint/types": "^8.57.0", "debug": "^4.4.3" }, "engines": { @@ -2669,14 +2669,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.56.1.tgz", - "integrity": "sha512-YAi4VDKcIZp0O4tz/haYKhmIDZFEUPOreKbfdAN3SzUDMcPhJ8QI99xQXqX+HoUVq8cs85eRKnD+rne2UAnj2w==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.57.0.tgz", + "integrity": "sha512-nvExQqAHF01lUM66MskSaZulpPL5pgy5hI5RfrxviLgzZVffB5yYzw27uK/ft8QnKXI2X0LBrHJFr1TaZtAibw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.56.1", - "@typescript-eslint/visitor-keys": "8.56.1" + "@typescript-eslint/types": "8.57.0", + "@typescript-eslint/visitor-keys": "8.57.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2687,9 +2687,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.56.1.tgz", - "integrity": "sha512-qOtCYzKEeyr3aR9f28mPJqBty7+DBqsdd63eO0yyDwc6vgThj2UjWfJIcsFeSucYydqcuudMOprZ+x1SpF3ZuQ==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.57.0.tgz", + "integrity": "sha512-LtXRihc5ytjJIQEH+xqjB0+YgsV4/tW35XKX3GTZHpWtcC8SPkT/d4tqdf1cKtesryHm2bgp6l555NYcT2NLvA==", "dev": true, "license": "MIT", "engines": { @@ -2704,15 +2704,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.56.1.tgz", - "integrity": "sha512-yB/7dxi7MgTtGhZdaHCemf7PuwrHMenHjmzgUW1aJpO+bBU43OycnM3Wn+DdvDO/8zzA9HlhaJ0AUGuvri4oGg==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.57.0.tgz", + "integrity": "sha512-yjgh7gmDcJ1+TcEg8x3uWQmn8ifvSupnPfjP21twPKrDP/pTHlEQgmKcitzF/rzPSmv7QjJ90vRpN4U+zoUjwQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.56.1", - "@typescript-eslint/typescript-estree": "8.56.1", - "@typescript-eslint/utils": "8.56.1", + "@typescript-eslint/types": "8.57.0", + "@typescript-eslint/typescript-estree": "8.57.0", + "@typescript-eslint/utils": "8.57.0", "debug": "^4.4.3", "ts-api-utils": "^2.4.0" }, @@ -2747,9 +2747,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.56.1.tgz", - "integrity": "sha512-dbMkdIUkIkchgGDIv7KLUpa0Mda4IYjo4IAMJUZ+3xNoUXxMsk9YtKpTHSChRS85o+H9ftm51gsK1dZReY9CVw==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.57.0.tgz", + "integrity": "sha512-dTLI8PEXhjUC7B9Kre+u0XznO696BhXcTlOn0/6kf1fHaQW8+VjJAVHJ3eTI14ZapTxdkOmc80HblPQLaEeJdg==", "dev": true, "license": "MIT", "engines": { @@ -2761,16 +2761,16 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.56.1.tgz", - "integrity": "sha512-qzUL1qgalIvKWAf9C1HpvBjif+Vm6rcT5wZd4VoMb9+Km3iS3Cv9DY6dMRMDtPnwRAFyAi7YXJpTIEXLvdfPxg==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.57.0.tgz", + "integrity": "sha512-m7faHcyVg0BT3VdYTlX8GdJEM7COexXxS6KqGopxdtkQRvBanK377QDHr4W/vIPAR+ah9+B/RclSW5ldVniO1Q==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.56.1", - "@typescript-eslint/tsconfig-utils": "8.56.1", - "@typescript-eslint/types": "8.56.1", - "@typescript-eslint/visitor-keys": "8.56.1", + "@typescript-eslint/project-service": "8.57.0", + "@typescript-eslint/tsconfig-utils": "8.57.0", + "@typescript-eslint/types": "8.57.0", + "@typescript-eslint/visitor-keys": "8.57.0", "debug": "^4.4.3", "minimatch": "^10.2.2", "semver": "^7.7.3", @@ -2846,16 +2846,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.56.1.tgz", - "integrity": "sha512-HPAVNIME3tABJ61siYlHzSWCGtOoeP2RTIaHXFMPqjrQKCGB9OgUVdiNgH7TJS2JNIQ5qQ4RsAUDuGaGme/KOA==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.57.0.tgz", + "integrity": "sha512-5iIHvpD3CZe06riAsbNxxreP+MuYgVUsV0n4bwLH//VJmgtt54sQeY2GszntJ4BjYCpMzrfVh2SBnUQTtys2lQ==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.56.1", - "@typescript-eslint/types": "8.56.1", - "@typescript-eslint/typescript-estree": "8.56.1" + "@typescript-eslint/scope-manager": "8.57.0", + "@typescript-eslint/types": "8.57.0", + "@typescript-eslint/typescript-estree": "8.57.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2870,13 +2870,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.56.1.tgz", - "integrity": "sha512-KiROIzYdEV85YygXw6BI/Dx4fnBlFQu6Mq4QE4MOH9fFnhohw6wX/OAvDY2/C+ut0I3RSPKenvZJIVYqJNkhEw==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.57.0.tgz", + "integrity": "sha512-zm6xx8UT/Xy2oSr2ZXD0pZo7Jx2XsCoID2IUh9YSTFRu7z+WdwYTRk6LhUftm1crwqbuoF6I8zAFeCMw0YjwDg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.56.1", + "@typescript-eslint/types": "8.57.0", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -5683,21 +5683,24 @@ "license": "MIT" }, "node_modules/fast-xml-builder": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.0.0.tgz", - "integrity": "sha512-fpZuDogrAgnyt9oDDz+5DBz0zgPdPZz6D4IR7iESxRXElrlGTRkHJ9eEt+SACRJwT0FNFrt71DFQIUFBJfX/uQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.1.4.tgz", + "integrity": "sha512-f2jhpN4Eccy0/Uz9csxh3Nu6q4ErKxf0XIsasomfOihuSUa3/xw6w8dnOtCDgEItQFJG8KyXPzQXzcODDrrbOg==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/NaturalIntelligence" } ], - "license": "MIT" + "license": "MIT", + "dependencies": { + "path-expression-matcher": "^1.1.3" + } }, "node_modules/fast-xml-parser": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.4.1.tgz", - "integrity": "sha512-BQ30U1mKkvXQXXkAGcuyUA/GA26oEB7NzOtsxCDtyu62sjGw5QraKFhx2Em3WQNjPw9PG6MQ9yuIIgkSDfGu5A==", + "version": "5.5.6", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.5.6.tgz", + "integrity": "sha512-3+fdZyBRVg29n4rXP0joHthhcHdPUHaIC16cuyyd1iLsuaO6Vea36MPrxgAzbZna8lhvZeRL8Bc9GP56/J9xEw==", "funding": [ { "type": "github", @@ -5706,7 +5709,8 @@ ], "license": "MIT", "dependencies": { - "fast-xml-builder": "^1.0.0", + "fast-xml-builder": "^1.1.4", + "path-expression-matcher": "^1.1.3", "strnum": "^2.1.2" }, "bin": { @@ -7836,6 +7840,21 @@ "node": ">=8" } }, + "node_modules/path-expression-matcher": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.1.3.tgz", + "integrity": "sha512-qdVgY8KXmVdJZRSS1JdEPOKPdTiEK/pi0RkcT2sw1RhXxohdujUlJFPuS1TSkevZ9vzd3ZlL7ULl1MHGTApKzQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/path-key": { "version": "3.1.1", "license": "MIT", @@ -9303,16 +9322,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.56.1", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.56.1.tgz", - "integrity": "sha512-U4lM6pjmBX7J5wk4szltF7I1cGBHXZopnAXCMXb3+fZ3B/0Z3hq3wS/CCUB2NZBNAExK92mCU2tEohWuwVMsDQ==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.57.0.tgz", + "integrity": "sha512-W8GcigEMEeB07xEZol8oJ26rigm3+bfPHxHvwbYUlu1fUDsGuQ7Hiskx5xGW/xM4USc9Ephe3jtv7ZYPQntHeA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.56.1", - "@typescript-eslint/parser": "8.56.1", - "@typescript-eslint/typescript-estree": "8.56.1", - "@typescript-eslint/utils": "8.56.1" + "@typescript-eslint/eslint-plugin": "8.57.0", + "@typescript-eslint/parser": "8.57.0", + "@typescript-eslint/typescript-estree": "8.57.0", + "@typescript-eslint/utils": "8.57.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/package.json b/package.json index 1a1044a7b2..876fa3e59d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codeql", - "version": "3.33.0", + "version": "3.34.0", "private": true, "description": "CodeQL action", "scripts": { @@ -45,7 +45,7 @@ }, "devDependencies": { "@ava/typescript": "6.0.0", - "@eslint/compat": "^2.0.2", + "@eslint/compat": "^2.0.3", "@microsoft/eslint-formatter-sarif": "^3.1.0", "@octokit/types": "^16.0.0", "@types/archiver": "^7.0.0", @@ -69,7 +69,7 @@ "nock": "^14.0.11", "sinon": "^21.0.2", "typescript": "^5.9.3", - "typescript-eslint": "^8.56.1" + "typescript-eslint": "^8.57.0" }, "overrides": { "@actions/tool-cache": { diff --git a/src/analyze.test.ts b/src/analyze.test.ts index 664c238535..0749a0cc26 100644 --- a/src/analyze.test.ts +++ b/src/analyze.test.ts @@ -10,6 +10,7 @@ import { defaultSuites, resolveQuerySuiteAlias, addSarifExtension, + diffRangeExtensionPackContents, } from "./analyze"; import { createStubCodeQL } from "./codeql"; import { Feature } from "./feature-flags"; @@ -158,3 +159,22 @@ test("addSarifExtension", (t) => { t.is(addSarifExtension(RiskAssessment, language), `${language}.csra.sarif`); } }); + +test("diffRangeExtensionPackContents", (t) => { + const output = diffRangeExtensionPackContents( + [ + { + path: "main.js", + startLine: 10, + endLine: 20, + }, + ], + "/checkout/path", + ); + + const expected = fs.readFileSync( + `${__dirname}/../src/testdata/pr-diff-range.yml`, + "utf8", + ); + t.deepEqual(output, expected); +}); diff --git a/src/analyze.ts b/src/analyze.ts index c7af4fec9f..8de1b98e81 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -5,7 +5,11 @@ import { performance } from "perf_hooks"; import * as io from "@actions/io"; import * as yaml from "js-yaml"; -import { getTemporaryDirectory, PullRequestBranches } from "./actions-util"; +import { + getTemporaryDirectory, + getRequiredInput, + PullRequestBranches, +} from "./actions-util"; import * as analyses from "./analyses"; import { setupCppAutobuild } from "./autobuild"; import { type CodeQL } from "./codeql"; @@ -243,7 +247,12 @@ export async function setupDiffInformedQueryRun( `Calculating diff ranges for ${branches.base}...${branches.head}`, ); const diffRanges = await getPullRequestEditedDiffRanges(branches, logger); - const packDir = writeDiffRangeDataExtensionPack(logger, diffRanges); + const checkoutPath = getRequiredInput("checkout_path"); + const packDir = writeDiffRangeDataExtensionPack( + logger, + diffRanges, + checkoutPath, + ); if (packDir === undefined) { logger.warning( "Cannot create diff range extension pack for diff-informed queries; " + @@ -259,6 +268,46 @@ export async function setupDiffInformedQueryRun( ); } +export function diffRangeExtensionPackContents( + ranges: DiffThunkRange[], + checkoutPath: string, +): string { + const header = ` +extensions: + - addsTo: + pack: codeql/util + extensible: restrictAlertsTo + checkPresence: false + data: +`; + + let data = ranges + .map((range) => { + // Diff-informed queries expect the file path to be absolute. CodeQL always + // uses forward slashes as the path separator, so on Windows we need to + // replace any backslashes with forward slashes. + const filename = path + .join(checkoutPath, range.path) + .replaceAll(path.sep, "/"); + + // Using yaml.dump() with `forceQuotes: true` ensures that all special + // characters are escaped, and that the path is always rendered as a + // quoted string on a single line. + return ( + ` - [${yaml.dump(filename, { forceQuotes: true }).trim()}, ` + + `${range.startLine}, ${range.endLine}]\n` + ); + }) + .join(""); + if (!data) { + // Ensure that the data extension is not empty, so that a pull request with + // no edited lines would exclude (instead of accepting) all alerts. + data = ' - ["", 0, 0]\n'; + } + + return header + data; +} + /** * Create an extension pack in the temporary directory that contains the file * line ranges that were added or modified in the pull request. @@ -266,12 +315,14 @@ export async function setupDiffInformedQueryRun( * @param logger * @param ranges The file line ranges, as returned by * `getPullRequestEditedDiffRanges`. + * @param checkoutPath The path at which the repository was checked out. * @returns The absolute path of the directory containing the extension pack, or * `undefined` if no extension pack was created. */ function writeDiffRangeDataExtensionPack( logger: Logger, ranges: DiffThunkRange[] | undefined, + checkoutPath: string, ): string | undefined { if (ranges === undefined) { return undefined; @@ -307,32 +358,10 @@ dataExtensions: `, ); - const header = ` -extensions: - - addsTo: - pack: codeql/util - extensible: restrictAlertsTo - checkPresence: false - data: -`; - - let data = ranges - .map( - (range) => - // Using yaml.dump() with `forceQuotes: true` ensures that all special - // characters are escaped, and that the path is always rendered as a - // quoted string on a single line. - ` - [${yaml.dump(range.path, { forceQuotes: true }).trim()}, ` + - `${range.startLine}, ${range.endLine}]\n`, - ) - .join(""); - if (!data) { - // Ensure that the data extension is not empty, so that a pull request with - // no edited lines would exclude (instead of accepting) all alerts. - data = ' - ["", 0, 0]\n'; - } - - const extensionContents = header + data; + const extensionContents = diffRangeExtensionPackContents( + ranges, + checkoutPath, + ); const extensionFilePath = path.join(diffRangeDir, "pr-diff-range.yml"); fs.writeFileSync(extensionFilePath, extensionContents); logger.debug( diff --git a/src/codeql.ts b/src/codeql.ts index 0a97d6b2c1..ee2773c01b 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -300,19 +300,6 @@ const GHES_MOST_RECENT_DEPRECATION_DATE = "2025-06-19"; /** The CLI verbosity level to use for extraction in debug mode. */ const EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++"; -/* - * Deprecated in favor of ToolsFeature. - * - * Versions of CodeQL that version-flag certain functionality in the Action. - * For convenience, please keep these in descending order. Once a version - * flag is older than the oldest supported version above, it may be removed. - */ - -/** - * Versions 2.17.1+ of the CodeQL CLI support the `--cache-cleanup` option. - */ -const CODEQL_VERSION_CACHE_CLEANUP = "2.17.1"; - /** * Set up CodeQL CLI access. * @@ -891,19 +878,13 @@ async function getCodeQLForCmd( config: Config, cleanupLevel: CleanupLevel, ): Promise { - const cacheCleanupFlag = (await util.codeQlVersionAtLeast( - this, - CODEQL_VERSION_CACHE_CLEANUP, - )) - ? "--cache-cleanup" - : "--mode"; for (const language of config.languages) { const databasePath = util.getCodeQLDatabasePath(config, language); const codeqlArgs = [ "database", "cleanup", databasePath, - `${cacheCleanupFlag}=${cleanupLevel}`, + `--cache-cleanup=${cleanupLevel}`, ...getExtraOptionsFromEnv(["database", "cleanup"]), ]; await runCli(cmd, codeqlArgs); diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index 1887f12734..0c14dcf9c4 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -26,6 +26,7 @@ import * as overlayStatus from "./overlay/status"; import { parseRepositoryNwo } from "./repository"; import { setupTests, + setupActionsVars, mockLanguagesInRepo as mockLanguagesInRepo, createFeatures, getRecordingLogger, @@ -64,7 +65,6 @@ function createTestInitConfigInputs( configInput: undefined, buildModeInput: undefined, ramInput: undefined, - trapCachingEnabled: false, dependencyCachingEnabled: CachingKind.None, debugMode: false, debugArtifactName: "", @@ -144,6 +144,8 @@ test.serial("load empty config", async (t) => { const logger = getRunnerLogger(true); const languages = "javascript,python"; + setupActionsVars(tempDir, tempDir); + const codeql = createStubCodeQL({ async betterResolveLanguages() { return { @@ -185,6 +187,8 @@ test.serial("load code quality config", async (t) => { const logger = getRunnerLogger(true); const languages = "actions"; + setupActionsVars(tempDir, tempDir); + const codeql = createStubCodeQL({ async betterResolveLanguages() { return { @@ -237,6 +241,8 @@ test.serial( const logger = getRunnerLogger(true); const languages = "javascript"; + setupActionsVars(tempDir, tempDir); + const codeql = createStubCodeQL({ async betterResolveLanguages() { return { @@ -475,6 +481,8 @@ test.serial("load non-existent input", async (t) => { test.serial("load non-empty input", async (t) => { return await withTmpDir(async (tempDir) => { + setupActionsVars(tempDir, tempDir); + const codeql = createStubCodeQL({ async betterResolveLanguages() { return { @@ -2013,13 +2021,13 @@ for (const language in KnownLanguage) { // Verify that a language without a per-language overlay feature flag cannot have // overlay analysis enabled, even when the base overlay feature flag is on. -// Using cpp here as it doesn't currently have overlay support — update this if -// cpp gains overlay support. +// Using swift here as it doesn't currently have overlay support — update this if +// swift gains overlay support. test.serial( checkOverlayEnablementMacro, "No overlay analysis for language without per-language overlay feature flag", { - languages: [KnownLanguage.cpp], + languages: [KnownLanguage.swift], features: [Feature.OverlayAnalysis], isPullRequest: true, }, @@ -2055,3 +2063,121 @@ test.serial("getPrimaryAnalysisConfig - Code Scanning + Code Quality", (t) => { AnalysisKind.CodeScanning, ); }); + +test.serial( + "isTrapCachingEnabled: explicit input true is respected", + async (t) => { + return await withTmpDir(async (tmpDir) => { + setupActionsVars(tmpDir, tmpDir); + sinon + .stub(actionsUtil, "getOptionalInput") + .withArgs("trap-caching") + .returns("true"); + t.true( + await configUtils.isTrapCachingEnabled( + createFeatures([]), + OverlayDatabaseMode.None, + ), + ); + }); + }, +); + +test.serial( + "isTrapCachingEnabled: disabled on self-hosted runner by default", + async (t) => { + return await withTmpDir(async (tmpDir) => { + setupActionsVars(tmpDir, tmpDir); + sinon + .stub(actionsUtil, "getOptionalInput") + .withArgs("trap-caching") + .returns(undefined); + t.false( + await configUtils.isTrapCachingEnabled( + createFeatures([]), + OverlayDatabaseMode.None, + ), + ); + }); + }, +); + +test.serial( + "isTrapCachingEnabled: enabled on hosted runner by default", + async (t) => { + return await withTmpDir(async (tmpDir) => { + const hostedToolCache = path.join(tmpDir, "hostedtoolcache"); + setupActionsVars(tmpDir, hostedToolCache); + sinon + .stub(actionsUtil, "getOptionalInput") + .withArgs("trap-caching") + .returns(undefined); + t.true( + await configUtils.isTrapCachingEnabled( + createFeatures([]), + OverlayDatabaseMode.None, + ), + ); + }); + }, +); + +test.serial( + "isTrapCachingEnabled: enabled on hosted runner when overlay enabled but feature flag off", + async (t) => { + return await withTmpDir(async (tmpDir) => { + const hostedToolCache = path.join(tmpDir, "hostedtoolcache"); + setupActionsVars(tmpDir, hostedToolCache); + sinon + .stub(actionsUtil, "getOptionalInput") + .withArgs("trap-caching") + .returns(undefined); + t.true( + await configUtils.isTrapCachingEnabled( + createFeatures([]), + OverlayDatabaseMode.Overlay, + ), + ); + }); + }, +); + +test.serial( + "isTrapCachingEnabled: disabled on hosted runner when overlay enabled and feature flag on", + async (t) => { + return await withTmpDir(async (tmpDir) => { + const hostedToolCache = path.join(tmpDir, "hostedtoolcache"); + setupActionsVars(tmpDir, hostedToolCache); + sinon + .stub(actionsUtil, "getOptionalInput") + .withArgs("trap-caching") + .returns(undefined); + t.false( + await configUtils.isTrapCachingEnabled( + createFeatures([Feature.OverlayAnalysisDisableTrapCaching]), + OverlayDatabaseMode.Overlay, + ), + ); + }); + }, +); + +test.serial( + "isTrapCachingEnabled: enabled on hosted runner when overlay is None even with feature flag on", + async (t) => { + return await withTmpDir(async (tmpDir) => { + const hostedToolCache = path.join(tmpDir, "hostedtoolcache"); + setupActionsVars(tmpDir, hostedToolCache); + sinon + .stub(actionsUtil, "getOptionalInput") + .withArgs("trap-caching") + .returns(undefined); + t.true( + await configUtils.isTrapCachingEnabled( + createFeatures([Feature.OverlayAnalysisDisableTrapCaching]), + OverlayDatabaseMode.None, + ), + ); + }); + }, +); diff --git a/src/config-utils.ts b/src/config-utils.ts index 67b3ae23d4..1721ec2900 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -2,10 +2,12 @@ import * as fs from "fs"; import * as path from "path"; import { performance } from "perf_hooks"; +import * as core from "@actions/core"; import * as yaml from "js-yaml"; import { getActionVersion, + getOptionalInput, isAnalyzingPullRequest, isDynamicWorkflow, } from "./actions-util"; @@ -72,6 +74,7 @@ import { Result, Success, Failure, + isHostedRunner, } from "./util"; /** @@ -452,7 +455,6 @@ export interface InitConfigInputs { configInput: string | undefined; buildModeInput: string | undefined; ramInput: string | undefined; - trapCachingEnabled: boolean; dependencyCachingEnabled: string | undefined; debugMode: boolean; debugArtifactName: string; @@ -482,7 +484,6 @@ export async function initActionState( packsInput, buildModeInput, dbLocation, - trapCachingEnabled, dependencyCachingEnabled, debugMode, debugArtifactName, @@ -540,13 +541,6 @@ export async function initActionState( }; } - const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime( - trapCachingEnabled, - codeql, - languages, - logger, - ); - // Compute the full Code Scanning configuration that combines the configuration from the // configuration file / `config` input with other inputs, such as `queries`. const computedConfig = generateCodeScanningConfig( @@ -569,8 +563,8 @@ export async function initActionState( debugMode, debugArtifactName, debugDatabaseName, - trapCaches, - trapCacheDownloadTime, + trapCaches: {}, + trapCacheDownloadTime: 0, dependencyCachingEnabled: getCachingKind(dependencyCachingEnabled), dependencyCachingRestoredKeys: [], extraQueryExclusions: [], @@ -582,7 +576,6 @@ export async function initActionState( } async function downloadCacheWithTime( - trapCachingEnabled: boolean, codeQL: CodeQL, languages: Language[], logger: Logger, @@ -590,13 +583,9 @@ async function downloadCacheWithTime( trapCaches: { [language: string]: string }; trapCacheDownloadTime: number; }> { - let trapCaches: { [language: string]: string } = {}; - let trapCacheDownloadTime = 0; - if (trapCachingEnabled) { - const start = performance.now(); - trapCaches = await downloadTrapCaches(codeQL, languages, logger); - trapCacheDownloadTime = performance.now() - start; - } + const start = performance.now(); + const trapCaches = await downloadTrapCaches(codeQL, languages, logger); + const trapCacheDownloadTime = performance.now() - start; return { trapCaches, trapCacheDownloadTime }; } @@ -636,6 +625,7 @@ async function loadUserConfig( * without an entry will have overlay analysis disabled. */ const OVERLAY_ANALYSIS_FEATURES: Partial> = { + cpp: Feature.OverlayAnalysisCpp, csharp: Feature.OverlayAnalysisCsharp, go: Feature.OverlayAnalysisGo, java: Feature.OverlayAnalysisJava, @@ -647,6 +637,7 @@ const OVERLAY_ANALYSIS_FEATURES: Partial> = { const OVERLAY_ANALYSIS_CODE_SCANNING_FEATURES: Partial< Record > = { + cpp: Feature.OverlayAnalysisCodeScanningCpp, csharp: Feature.OverlayAnalysisCodeScanningCsharp, go: Feature.OverlayAnalysisCodeScanningGo, java: Feature.OverlayAnalysisCodeScanningJava, @@ -1009,6 +1000,50 @@ async function validateOverlayDatabaseMode( }); } +export async function isTrapCachingEnabled( + features: FeatureEnablement, + overlayDatabaseMode: OverlayDatabaseMode, +): Promise { + // If the workflow specified something, always respect that. + const trapCaching = getOptionalInput("trap-caching"); + if (trapCaching !== undefined) return trapCaching === "true"; + + // On self-hosted runners which may have slow network access, disable TRAP caching by default. + if (!isHostedRunner()) return false; + + // If overlay analysis is enabled, then disable TRAP caching since overlay analysis supersedes it. + // This change is gated behind a feature flag. + if ( + overlayDatabaseMode !== OverlayDatabaseMode.None && + (await features.getValue(Feature.OverlayAnalysisDisableTrapCaching)) + ) { + return false; + } + + // Otherwise, enable TRAP caching. + return true; +} + +async function setCppTrapCachingEnvironmentVariables( + config: Config, + logger: Logger, +): Promise { + if (config.languages.includes(KnownLanguage.cpp)) { + const envVar = "CODEQL_EXTRACTOR_CPP_TRAP_CACHING"; + if (process.env[envVar]) { + logger.info( + `Environment variable ${envVar} already set, leaving it unchanged.`, + ); + } else if (config.trapCaches[KnownLanguage.cpp]) { + logger.info("Enabling TRAP caching for C/C++."); + core.exportVariable(envVar, "true"); + } else { + logger.debug(`Disabling TRAP caching for C/C++.`); + core.exportVariable(envVar, "false"); + } + } +} + function dbLocationOrDefault( dbLocation: string | undefined, tempDir: string, @@ -1199,6 +1234,19 @@ export async function initConfig( exclude: { tags: "exclude-from-incremental" }, }); } + + if (await isTrapCachingEnabled(features, config.overlayDatabaseMode)) { + const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime( + inputs.codeql, + config.languages, + logger, + ); + config.trapCaches = trapCaches; + config.trapCacheDownloadTime = trapCacheDownloadTime; + } + + await setCppTrapCachingEnvironmentVariables(config, logger); + return config; } diff --git a/src/defaults.json b/src/defaults.json index 9b6ec84bd4..c327217afe 100644 --- a/src/defaults.json +++ b/src/defaults.json @@ -1,6 +1,6 @@ { - "bundleVersion": "codeql-bundle-v2.24.3", - "cliVersion": "2.24.3", - "priorBundleVersion": "codeql-bundle-v2.24.2", - "priorCliVersion": "2.24.2" + "bundleVersion": "codeql-bundle-v2.25.0", + "cliVersion": "2.25.0", + "priorBundleVersion": "codeql-bundle-v2.24.3", + "priorCliVersion": "2.24.3" } diff --git a/src/diff-informed-analysis-utils.test.ts b/src/diff-informed-analysis-utils.test.ts index 44b7e77917..bec0c2c0ab 100644 --- a/src/diff-informed-analysis-utils.test.ts +++ b/src/diff-informed-analysis-utils.test.ts @@ -188,10 +188,6 @@ test.serial( ); function runGetDiffRanges(changes: number, patch: string[] | undefined): any { - sinon - .stub(actionsUtil, "getRequiredInput") - .withArgs("checkout_path") - .returns("/checkout/path"); return exportedForTesting.getDiffRanges( { filename: "test.txt", @@ -211,7 +207,7 @@ test.serial("getDiffRanges: file diff too large", async (t) => { const diffRanges = runGetDiffRanges(1000000, undefined); t.deepEqual(diffRanges, [ { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 0, endLine: 0, }, @@ -234,7 +230,7 @@ test.serial( ]); t.deepEqual(diffRanges, [ { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 53, endLine: 54, }, @@ -274,7 +270,7 @@ test.serial("getDiffRanges: diff thunk with single update range", async (t) => { ]); t.deepEqual(diffRanges, [ { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 53, endLine: 53, }, @@ -296,12 +292,12 @@ test.serial("getDiffRanges: diff thunk with addition ranges", async (t) => { ]); t.deepEqual(diffRanges, [ { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 53, endLine: 53, }, { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 55, endLine: 55, }, @@ -328,12 +324,12 @@ test.serial("getDiffRanges: diff thunk with mixed ranges", async (t) => { ]); t.deepEqual(diffRanges, [ { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 54, endLine: 54, }, { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 57, endLine: 58, }, @@ -363,12 +359,12 @@ test.serial("getDiffRanges: multiple diff thunks", async (t) => { ]); t.deepEqual(diffRanges, [ { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 53, endLine: 54, }, { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 153, endLine: 154, }, @@ -379,7 +375,7 @@ test.serial("getDiffRanges: no diff context lines", async (t) => { const diffRanges = runGetDiffRanges(2, ["@@ -30 +50,2 @@", "+1", "+2"]); t.deepEqual(diffRanges, [ { - path: "/checkout/path/test.txt", + path: "test.txt", startLine: 50, endLine: 51, }, diff --git a/src/diff-informed-analysis-utils.ts b/src/diff-informed-analysis-utils.ts index 4f3a89d9fa..ac0eb1ea26 100644 --- a/src/diff-informed-analysis-utils.ts +++ b/src/diff-informed-analysis-utils.ts @@ -71,6 +71,7 @@ export async function getDiffInformedAnalysisBranches( } export interface DiffThunkRange { + /** Relative path from the repository root, using forward slashes as separators. */ path: string; startLine: number; endLine: number; @@ -112,8 +113,9 @@ export function readDiffRangesJsonFile( * * @param branches The base and head branches of the pull request. * @param logger - * @returns An array of tuples, where each tuple contains the absolute path of a - * file, the start line and the end line (both 1-based and inclusive) of an + * @returns An array of tuples, where each tuple contains the relative path of a + * file (relative to the repository root, as returned by the GitHub compare API), + * the start line and the end line (both 1-based and inclusive) of an * added or modified range in that file. Returns `undefined` if the action was * not triggered by a pull request or if there was an error. */ @@ -191,13 +193,6 @@ function getDiffRanges( fileDiff: FileDiff, logger: Logger, ): DiffThunkRange[] | undefined { - // Diff-informed queries expect the file path to be absolute. CodeQL always - // uses forward slashes as the path separator, so on Windows we need to - // replace any backslashes with forward slashes. - const filename = path - .join(actionsUtil.getRequiredInput("checkout_path"), fileDiff.filename) - .replaceAll(path.sep, "/"); - if (fileDiff.patch === undefined) { if (fileDiff.changes === 0) { // There are situations where a changed file legitimately has no diff. @@ -212,7 +207,7 @@ function getDiffRanges( // to a special diff range that covers the entire file. return [ { - path: filename, + path: fileDiff.filename, startLine: 0, endLine: 0, }, @@ -247,7 +242,7 @@ function getDiffRanges( // Any line that does not start with a "+" or "-" terminates the current // range of added lines. diffRanges.push({ - path: filename, + path: fileDiff.filename, startLine: additionRangeStartLine, endLine: currentLine - 1, }); diff --git a/src/feature-flags.ts b/src/feature-flags.ts index e45d7f93c9..9fa9b9590c 100644 --- a/src/feature-flags.ts +++ b/src/feature-flags.ts @@ -9,6 +9,7 @@ import * as defaults from "./defaults.json"; import { Logger } from "./logging"; import { CODEQL_OVERLAY_MINIMUM_VERSION, + CODEQL_OVERLAY_MINIMUM_VERSION_CPP, CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP, CODEQL_OVERLAY_MINIMUM_VERSION_GO, CODEQL_OVERLAY_MINIMUM_VERSION_JAVA, @@ -57,18 +58,18 @@ export enum Feature { IgnoreGeneratedFiles = "ignore_generated_files", JavaNetworkDebugging = "java_network_debugging", OverlayAnalysis = "overlay_analysis", + OverlayAnalysisCodeScanningCpp = "overlay_analysis_code_scanning_cpp", OverlayAnalysisCodeScanningCsharp = "overlay_analysis_code_scanning_csharp", OverlayAnalysisCodeScanningGo = "overlay_analysis_code_scanning_go", OverlayAnalysisCodeScanningJava = "overlay_analysis_code_scanning_java", OverlayAnalysisCodeScanningJavascript = "overlay_analysis_code_scanning_javascript", OverlayAnalysisCodeScanningPython = "overlay_analysis_code_scanning_python", OverlayAnalysisCodeScanningRuby = "overlay_analysis_code_scanning_ruby", + OverlayAnalysisCpp = "overlay_analysis_cpp", OverlayAnalysisCsharp = "overlay_analysis_csharp", + /** Disable TRAP caching when overlay analysis is enabled. */ + OverlayAnalysisDisableTrapCaching = "overlay_analysis_disable_trap_caching", OverlayAnalysisGo = "overlay_analysis_go", - /** Controls whether the Actions cache is checked for overlay build outcomes. */ - OverlayAnalysisStatusCheck = "overlay_analysis_status_check", - /** Controls whether overlay build failures on are stored in the Actions cache. */ - OverlayAnalysisStatusSave = "overlay_analysis_status_save", OverlayAnalysisJava = "overlay_analysis_java", OverlayAnalysisJavascript = "overlay_analysis_javascript", OverlayAnalysisPython = "overlay_analysis_python", @@ -80,6 +81,10 @@ export enum Feature { OverlayAnalysisRuby = "overlay_analysis_ruby", /** Controls whether hardware checks are skipped for overlay analysis. */ OverlayAnalysisSkipResourceChecks = "overlay_analysis_skip_resource_checks", + /** Controls whether the Actions cache is checked for overlay build outcomes. */ + OverlayAnalysisStatusCheck = "overlay_analysis_status_check", + /** Controls whether overlay build failures on the default branch are stored in the Actions cache. */ + OverlayAnalysisStatusSave = "overlay_analysis_status_save", PythonDefaultIsToNotExtractStdlib = "python_default_is_to_not_extract_stdlib", QaTelemetryEnabled = "qa_telemetry_enabled", /** Note that this currently only disables baseline file coverage information. */ @@ -197,6 +202,11 @@ export const featureConfig = { // Per-language overlay feature flags. Each has minimumVersion set to the // minimum CLI version that supports overlay analysis for that language. // Only languages that are GA or in staff-ship should have feature flags here. + [Feature.OverlayAnalysisCodeScanningCpp]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP, + }, [Feature.OverlayAnalysisCodeScanningCsharp]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_CSHARP", @@ -227,6 +237,11 @@ export const featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CODE_SCANNING_RUBY", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY, }, + [Feature.OverlayAnalysisCpp]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CPP", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_CPP, + }, [Feature.OverlayAnalysisCsharp]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_CSHARP", @@ -237,16 +252,6 @@ export const featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_GO", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_GO, }, - [Feature.OverlayAnalysisStatusCheck]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", - minimumVersion: undefined, - }, - [Feature.OverlayAnalysisStatusSave]: { - defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", - minimumVersion: undefined, - }, [Feature.OverlayAnalysisJava]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_JAVA", @@ -262,15 +267,31 @@ export const featureConfig = { envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_PYTHON", minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_PYTHON, }, + [Feature.OverlayAnalysisRuby]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", + minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY, + }, + // Other overlay-related feature flags + [Feature.OverlayAnalysisDisableTrapCaching]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_DISABLE_TRAP_CACHING", + minimumVersion: undefined, + }, [Feature.OverlayAnalysisResourceChecksV2]: { defaultValue: false, envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RESOURCE_CHECKS_V2", minimumVersion: undefined, }, - [Feature.OverlayAnalysisRuby]: { + [Feature.OverlayAnalysisStatusCheck]: { defaultValue: false, - envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_RUBY", - minimumVersion: CODEQL_OVERLAY_MINIMUM_VERSION_RUBY, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_CHECK", + minimumVersion: undefined, + }, + [Feature.OverlayAnalysisStatusSave]: { + defaultValue: false, + envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS_STATUS_SAVE", + minimumVersion: undefined, }, [Feature.OverlayAnalysisSkipResourceChecks]: { defaultValue: false, diff --git a/src/init-action.ts b/src/init-action.ts index 56902a4379..6fe89165bd 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -88,7 +88,6 @@ import { getRequiredEnvParam, getThreadsFlagValue, initializeEnvironment, - isHostedRunner, ConfigurationError, wrapError, checkActionVersion, @@ -362,7 +361,6 @@ async function run(startedAt: Date) { configFile, dbLocation: getOptionalInput("db-location"), configInput: getOptionalInput("config"), - trapCachingEnabled: getTrapCachingEnabled(), dependencyCachingEnabled: getDependencyCachingEnabled(), // Debug mode is enabled if: // - The `init` Action is passed `debug: true`. @@ -613,24 +611,6 @@ async function run(startedAt: Date) { core.exportVariable(kotlinLimitVar, "2.1.20"); } - if (config.languages.includes(KnownLanguage.cpp)) { - const envVar = "CODEQL_EXTRACTOR_CPP_TRAP_CACHING"; - if (process.env[envVar]) { - logger.info( - `Environment variable ${envVar} already set. Not en/disabling CodeQL C++ TRAP caching support`, - ); - } else if ( - getTrapCachingEnabled() && - (await codeQlVersionAtLeast(codeql, "2.17.5")) - ) { - logger.info("Enabling CodeQL C++ TRAP caching support"); - core.exportVariable(envVar, "true"); - } else { - logger.info("Disabling CodeQL C++ TRAP caching support"); - core.exportVariable(envVar, "false"); - } - } - // Restore dependency cache(s), if they exist. if (shouldRestoreCache(config.dependencyCachingEnabled)) { const dependencyCachingResult = await downloadDependencyCaches( @@ -644,17 +624,6 @@ async function run(startedAt: Date) { dependencyCachingResult.restoredKeys; } - // Suppress warnings about disabled Python library extraction. - if (await codeQlVersionAtLeast(codeql, "2.17.1")) { - // disabled by default, no warning - } else { - // disabled by default, prints warning if environment variable is not set - core.exportVariable( - "CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION", - "true", - ); - } - if (getOptionalInput("setup-python-dependencies") !== undefined) { logger.warning( "The setup-python-dependencies input is deprecated and no longer has any effect. We recommend removing any references from your workflows. See https://github.blog/changelog/2024-01-23-codeql-2-16-python-dependency-installation-disabled-new-queries-and-bug-fixes/ for more information.", @@ -864,18 +833,6 @@ async function loadRepositoryProperties( } } -function getTrapCachingEnabled(): boolean { - // If the workflow specified something always respect that - const trapCaching = getOptionalInput("trap-caching"); - if (trapCaching !== undefined) return trapCaching === "true"; - - // On self-hosted runners which may have slow network access, disable TRAP caching by default - if (!isHostedRunner()) return false; - - // On hosted runners, enable TRAP caching by default - return true; -} - async function recordZstdAvailability( config: configUtils.Config, zstdAvailability: ZstdAvailability, diff --git a/src/overlay/index.ts b/src/overlay/index.ts index 3b45a60d44..63a46b2b39 100644 --- a/src/overlay/index.ts +++ b/src/overlay/index.ts @@ -35,6 +35,7 @@ export const CODEQL_OVERLAY_MINIMUM_VERSION = "2.23.8"; // Per-language minimum CLI versions for overlay analysis, based on release // validation data. +export const CODEQL_OVERLAY_MINIMUM_VERSION_CPP = "2.25.0"; export const CODEQL_OVERLAY_MINIMUM_VERSION_CSHARP = "2.24.1"; export const CODEQL_OVERLAY_MINIMUM_VERSION_GO = "2.24.2"; export const CODEQL_OVERLAY_MINIMUM_VERSION_JAVA = "2.23.8"; diff --git a/src/testdata/pr-diff-range.yml b/src/testdata/pr-diff-range.yml new file mode 100644 index 0000000000..073b83198a --- /dev/null +++ b/src/testdata/pr-diff-range.yml @@ -0,0 +1,8 @@ + +extensions: + - addsTo: + pack: codeql/util + extensible: restrictAlertsTo + checkPresence: false + data: + - ['/checkout/path/main.js', 10, 20] diff --git a/src/testdata/valid-sarif-diff-filtered.sarif b/src/testdata/valid-sarif-diff-filtered.sarif new file mode 100644 index 0000000000..4c92c147e2 --- /dev/null +++ b/src/testdata/valid-sarif-diff-filtered.sarif @@ -0,0 +1,178 @@ +{ + "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", + "version": "2.1.0", + "runs": [{ + "tool": { + "driver": { + "name": "LGTM.com", + "organization": "Semmle", + "version": "1.24.0-SNAPSHOT", + "rules": [{ + "id": "js/unused-local-variable", + "name": "js/unused-local-variable", + "shortDescription": { + "text": "Unused variable, import, function or class" + }, + "fullDescription": { + "text": "Unused variables, imports, functions or classes may be a symptom of a bug and should be examined carefully." + }, + "defaultConfiguration": { + "level": "note" + }, + "properties": { + "tags": ["maintainability"], + "kind": "problem", + "precision": "very-high", + "name": "Unused variable, import, function or class", + "description": "Unused variables, imports, functions or classes may be a symptom of a bug\n and should be examined carefully.", + "id": "js/unused-local-variable", + "problem.severity": "recommendation" + } + }] + } + }, + "results": [{ + "ruleId": "js/unused-local-variable", + "ruleIndex": 0, + "message": { + "text": "Unused variable foo." + }, + "locations": [{ + "physicalLocation": { + "artifactLocation": { + "uri": "main.js", + "uriBaseId": "%SRCROOT%", + "index": 0 + }, + "region": { + "startLine": 2, + "startColumn": 7, + "endColumn": 10 + } + } + }], + "partialFingerprints": { + "primaryLocationLineHash": "39fa2ee980eb94b0:1", + "primaryLocationStartColumnFingerprint": "4" + } + }], + "columnKind": "utf16CodeUnits", + "properties": { + "semmle.formatSpecifier": "2.1.0", + "semmle.sourceLanguage": "java" + } + }, + { + "tool" : { + "driver" : { + "name" : "CodeQL command-line toolchain", + "organization" : "GitHub", + "semanticVersion" : "2.0.0", + "rules" : [ { + "id" : "js/unused-local-variable", + "name" : "js/unused-local-variable", + "shortDescription" : { + "text" : "Unused variable, import, function or class" + }, + "fullDescription" : { + "text" : "Unused variables, imports, functions or classes may be a symptom of a bug and should be examined carefully." + }, + "defaultConfiguration" : { + "level": "note" + }, + "properties" : { + "tags" : [ "maintainability" ], + "kind" : "problem", + "precision" : "very-high", + "name" : "Unused variable, import, function or class", + "description" : "Unused variables, imports, functions or classes may be a symptom of a bug\n and should be examined carefully.", + "id" : "js/unused-local-variable", + "problem.severity" : "recommendation" + } + }, + { + "id": "js/inconsistent-use-of-new", + "name": "js/inconsistent-use-of-new", + "shortDescription": { + "text": "Inconsistent use of 'new'" + }, + "fullDescription": { + "text": "If a function is intended to be a constructor, it should always be invoked with 'new'. Otherwise, it should always be invoked as a normal function, that is, without 'new'." + }, + "defaultConfiguration": { + "level": "note" + }, + "properties": { + "tags": [ + "reliability", + "correctness", + "language-features" + ], + "kind": "problem", + "precision": "very-high", + "problem.severity": "warning" + } + } ] + } + }, + "artifacts" : [ { + "location" : { + "uri" : "main.js", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + } + }, + { + "location": { + "uri": "src/promiseUtils.js", + "uriBaseId": "%SRCROOT%", + "index": 1 + } + }, + { + "location": { + "uri": "src/LiveQueryClient.js", + "uriBaseId": "%SRCROOT%", + "index": 2 + } + }, + { + "location": { + "uri": "src/ParseObject.js", + "uriBaseId": "%SRCROOT%", + "index": 3 + } + } ], + "results" : [ { + "ruleId" : "js/unused-local-variable", + "ruleIndex" : 0, + "message" : { + "text" : "Unused variable foo." + }, + "locations" : [ { + "physicalLocation" : { + "artifactLocation" : { + "uri" : "main.js", + "uriBaseId" : "%SRCROOT%", + "index" : 0 + }, + "region" : { + "startLine" : 2, + "startColumn" : 7, + "endColumn" : 10 + } + } + } ], + "partialFingerprints" : { + "primaryLocationLineHash" : "39fa2ee980eb94b0:1", + "primaryLocationStartColumnFingerprint" : "4" + } + }], + "newlineSequences" : [ "\r\n", "\n", "
", "
" ], + "columnKind" : "utf16CodeUnits", + "properties" : { + "semmle.formatSpecifier" : "sarif-latest" + } + } + ] +} \ No newline at end of file diff --git a/src/testing-utils.ts b/src/testing-utils.ts index 8a7cf8e2d9..4c61f94b1d 100644 --- a/src/testing-utils.ts +++ b/src/testing-utils.ts @@ -156,6 +156,7 @@ export const DEFAULT_ACTIONS_VARS = { GITHUB_SERVER_URL: "https://github.com", GITHUB_SHA: "0".repeat(40), GITHUB_WORKFLOW: "test-workflow", + RUNNER_NAME: "my-runner", RUNNER_OS: "Linux", } as const satisfies Record; diff --git a/src/upload-lib.test.ts b/src/upload-lib.test.ts index e1990a811b..2c27d56c1c 100644 --- a/src/upload-lib.test.ts +++ b/src/upload-lib.test.ts @@ -9,6 +9,7 @@ import * as sinon from "sinon"; import * as analyses from "./analyses"; import { AnalysisKind, CodeQuality, CodeScanning } from "./analyses"; import * as api from "./api-client"; +import * as diffUtils from "./diff-informed-analysis-utils"; import { getRunnerLogger, Logger } from "./logging"; import * as sarif from "./sarif"; import { setupTests } from "./testing-utils"; @@ -1012,3 +1013,33 @@ for (const analysisKind of analyses.supportedAnalysisKinds) { }, ); } + +function runFilterAlertsByDiffRange( + input: Partial, + diffRanges: diffUtils.DiffThunkRange[], +): Partial { + sinon.stub(diffUtils, "readDiffRangesJsonFile").returns(diffRanges); + return uploadLib.filterAlertsByDiffRange(getRunnerLogger(true), input); +} + +test.serial( + "filterAlertsByDiffRange filters out alerts outside diff-range", + (t) => { + const input = sarif.readSarifFile( + `${__dirname}/../src/testdata/valid-sarif.sarif`, + ); + const actualOutput = runFilterAlertsByDiffRange(input, [ + { + path: "main.js", + startLine: 1, + endLine: 3, + }, + ]); + + const expectedOutput = sarif.readSarifFile( + `${__dirname}/../src/testdata/valid-sarif-diff-filtered.sarif`, + ); + + t.deepEqual(actualOutput, expectedOutput); + }, +); diff --git a/src/upload-lib.ts b/src/upload-lib.ts index 101e7946fc..2464fe5eaa 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -1039,7 +1039,7 @@ function sanitize(str?: string) { return (str ?? "_").replace(/[^a-zA-Z0-9_]/g, "_").toLocaleUpperCase(); } -function filterAlertsByDiffRange( +export function filterAlertsByDiffRange( logger: Logger, sarifLog: Partial, ): Partial { @@ -1052,8 +1052,6 @@ function filterAlertsByDiffRange( return sarifLog; } - const checkoutPath = actionsUtil.getRequiredInput("checkout_path"); - for (const run of sarifLog.runs) { if (run.results) { run.results = run.results.filter((result) => { @@ -1068,11 +1066,6 @@ function filterAlertsByDiffRange( if (!locationUri || locationStartLine === undefined) { return false; } - // CodeQL always uses forward slashes as the path separator, so on Windows we - // need to replace any backslashes with forward slashes. - const locationPath = path - .join(checkoutPath, locationUri) - .replaceAll(path.sep, "/"); // Alert filtering here replicates the same behavior as the restrictAlertsTo // extensible predicate in CodeQL. See the restrictAlertsTo documentation // https://codeql.github.com/codeql-standard-libraries/csharp/codeql/util/AlertFiltering.qll/predicate.AlertFiltering$restrictAlertsTo.3.html @@ -1080,7 +1073,7 @@ function filterAlertsByDiffRange( // of an alert location. return diffRanges.some( (range) => - range.path === locationPath && + range.path === locationUri && ((range.startLine <= locationStartLine && range.endLine >= locationStartLine) || (range.startLine === 0 && range.endLine === 0)),