diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index a369455cdf..f62fcc2301 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -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(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 + ";"; + } + 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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 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; })(); } diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 69c780edfc..1ea8e16ce9 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -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 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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 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; })(); } diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 72c0d30376..3f53b14766 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -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 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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 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; })(); } diff --git a/lib/init-action-post.js b/lib/init-action-post.js index bf1d298127..e3cfccf5b9 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 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; })(); } diff --git a/lib/init-action.js b/lib/init-action.js index 70393eab63..966f2f82ce 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -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(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) { @@ -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 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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 lt2(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 : 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; })(); } diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index 25fc651920..8049f208b5 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -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 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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 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; })(); } diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 472349d1b1..31b0568d1b 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -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(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) { @@ -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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 '&'"); @@ -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; })(); } diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index d76e675601..3bee491f13 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -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(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 + ";"; + } + 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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 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; })(); } diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 6b88aef405..1617f4e378 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -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(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) { @@ -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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 '&'"); @@ -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; })(); } diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 87fd293200..247204f8ed 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -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 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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 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; })(); } diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index 4190b06e5a..428ff31833 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -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(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) { @@ -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 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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 '&'"); @@ -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; })(); } diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 27998f510c..8cf5293259 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -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(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) { @@ -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 Q = I.getMetaDataSymbol(); - function J(t2, e2) { - return H(t2, e2); + 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 '&'"); @@ -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; })(); } diff --git a/package-lock.json b/package-lock.json index aea96aac8a..5b67cc2813 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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",