diff --git a/dist/index.js b/dist/index.js index fb56387c..5f330ecf 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13559,16 +13559,16 @@ function range(a, b, str) { /***/ 33717: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -var concatMap = __nccwpck_require__(86891); -var balanced = __nccwpck_require__(9417); +var concatMap = __nccwpck_require__(86891) +var balanced = __nccwpck_require__(9417) -module.exports = expandTop; +module.exports = expandTop -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; +var escSlash = '\0SLASH' + Math.random().toFixed(16) + '\0' +var escOpen = '\0OPEN' + Math.random().toFixed(16) + '\0' +var escClose = '\0CLOSE' + Math.random().toFixed(16) + '\0' +var escComma = '\0COMMA' + Math.random().toFixed(16) + '\0' +var escPeriod = '\0PERIOD' + Math.random().toFixed(16) + '\0' var EXPANSION_MAX = 100000 @@ -13584,66 +13584,236 @@ var EXPANSION_MAX = 100000 // characters) so legitimate input is unaffected. var EXPANSION_MAX_LENGTH = 4000000 +// `expand` recurses once per level of brace *nesting* - both when expanding a +// set's comma members and when re-wrapping a set whose body is a single part. +// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one +// level per chained group), which left nesting depth unbounded: about 3,100 +// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack +// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser +// will follow nesting. It sits far above any realistic pattern and well below +// the depth at which the stack runs out. +var EXPANSION_MAX_DEPTH = 1000 + +// Bash keeps a quirk where a brace group followed by a comma set still expands +// (`{a},b}`). The parser implements it by rewriting the string and restarting +// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n` +// full passes over a string that itself grows by one `escClose` sentinel each +// time - quadratic in `n`, with a ~26x constant from the sentinel's length. +// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27 +// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many +// times the scan may restart. Real `{a},b}` input needs a handful. +var EXPANSION_MAX_REWRITES = 1000 + +// `EXPANSION_MAX_STEPS` bounds the work one `expandTop` call does, which `max`, +// `maxLength` and `maxDepth` don't: nested sets are rescanned at every level +// and chained groups each rebuild up to `max` results, so 2KB of input could +// block the event loop for over 30 seconds. Each character scanned, result +// built and sequence value generated is a step, and each `expand` call costs +// `CALL_STEPS` more. Past the budget, the set being expanded and everything +// after it stay literal. A glob needs a few hundred steps, and nesting all the +// way to `EXPANSION_MAX_DEPTH` about 4M. +var EXPANSION_MAX_STEPS = 20000000 + +// What one `expand` call costs on top of what it scans and builds. Setting +// one up takes about as long as scanning 16 characters, and a set whose +// results are wrapped to be expanded again makes one call per result, each +// scanning and building next to nothing: 64KB of +// `('{{' + ','.repeat(316) + '}{' + ','.repeat(316) + '}}').repeat(n)` made +// 4M such calls, which spent the budget three times as slowly as anything +// else. +var CALL_STEPS = 16 + function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); + return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0) } function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); + return str + .split('\\\\') + .join(escSlash) + .split('\\{') + .join(escOpen) + .split('\\}') + .join(escClose) + .split('\\,') + .join(escComma) + .split('\\.') + .join(escPeriod) } function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); + return str + .split(escSlash) + .join('\\') + .split(escOpen) + .join('{') + .split(escClose) + .join('}') + .split(escComma) + .join(',') + .split(escPeriod) + .join('.') } +// Like `target.push(...items)` but doesn't overflow the stack +function pushAll(target, items) { + for (var i = 0; i < items.length; i++) { + target.push(items[i]) + } +} + +// `balanced`, run on `masked` (see `maskUnmatchedOpens`), sliced from `str` +// and charged for the characters it walks: up to the group's `}`, or the +// whole string when there is no match or unmatched `{` come first, which +// `unmatched` then flags for masking. Once a call overdraws the budget, it +// and every later one return undefined, so the rest stays literal. +// +// `budget` is `{ remaining }`, one counter shared by every level and group of +// an `expandTop` call, so the bound holds for the call as a whole. +function balancedWithBudget(str, masked, budget) { + if (budget.remaining < 0) { + return undefined + } + var r = balanced.range('{', '}', masked) + var unmatched = r !== undefined && masked.indexOf('{') < r[0] + budget.remaining -= r && !unmatched ? r[1] + 1 : str.length + if (!r || budget.remaining < 0) { + return undefined + } + return { + end: r[1], + pre: str.slice(0, r[0]), + body: str.slice(r[0] + 1, r[1]), + post: str.slice(r[1] + 1), + unmatched: unmatched, + } +} + +// `masked` with every `{` that has no matching `}` swapped for a `\0`, which +// keeps the length, so a scan of it still lines up with the string it was +// made from. Such a `{` is literal either way, but `balanced` only learns that +// one is unmatched by reading to the end of the string, so with one at the +// head of every group (`'{a,{b,c}'.repeat(n)`) each scan read the rest of the +// input. That was quadratic, and once the step budget charged for it, it ran +// out partway through and left the rest literal. A scan of the masked copy +// stops at the group's `}`. It is one pass, charged as such. +function maskUnmatchedOpens(masked, budget) { + budget.remaining -= masked.length + var open = [] + for (var i = 0; i < masked.length; i++) { + var c = masked.charCodeAt(i) + if (c === 0x7b) { + open.push(i) + } else if (c === 0x7d && open.length) { + open.pop() + } + } + var out = '' + var last = 0 + for (var j = 0; j < open.length; j++) { + out += masked.slice(last, open[j]) + '\0' + last = open[j] + 1 + } + return out + masked.slice(last) +} + +// Whether `str` has a `,` not followed by another `,`, with a `}` after it on +// the same line - what `/,(?!,).*\}/.test(str)` asks, answered in one pass from +// the end. The regex tries every `,` and backtracks through the rest of its +// line from each, which is quadratic, and the `{a},b}` rewrite asks again on +// every pass. Like a scan, it is charged for the whole string and refused if +// that overdraws the budget. +function commaSetFollows(str, budget) { + budget.remaining -= str.length + if (budget.remaining < 0) { + return false + } + // Whether a `}` follows the current position before the line ends + var close = false + for (var i = str.length - 1; i >= 0; i--) { + var c = str.charCodeAt(i) + if (c === 0x7d) { + close = true + } else if (c === 0x0a || c === 0x0d || c === 0x2028 || c === 0x2029) { + // A line terminator, which `.` does not match + close = false + } else if (c === 0x2c && close && str.charCodeAt(i + 1) !== 0x2c) { + return true + } + } + return false +} // Basically just str.split(","), but handling cases // where we have nested braced sections, which should be // treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; +// +// Returns `undefined` if the step budget runs out before the whole set is +// split, since splitting what is left on every comma would tear apart the +// nested sets it still holds. +function parseCommaParts(str, budget) { + var parts = [] - var parts = []; - var m = balanced('{', '}', str); + // Walk the brace groups iteratively. Recursing on `post` once per group let a + // chain of them exhaust the stack - the parsing-side counterpart to + // the `expand` overflow fixed for CVE-2026-14257, and not something `max` or + // `maxLength` can bound, since it happens before expansion. + // + // The part the next chunk continues + var carry = '' - if (!m) - return str.split(','); + for (;;) { + // A set's body holds no unmatched `{`, so there is nothing to mask. + var m = balancedWithBudget(str, str, budget) - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); + if (budget.remaining < 0) { + return undefined + } - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); + if (!m) { + var tail = str.split(',') + tail[0] = carry + tail[0] + pushAll(parts, tail) + return parts + } + + var pre = m.pre + var body = m.body + var post = m.post + var p = pre.split(',') + + p[0] = carry + p[0] + p[p.length - 1] += '{' + body + '}' + + if (!post.length) { + pushAll(parts, p) + return parts + } + + carry = p.pop() + pushAll(parts, p) + str = post } +} - parts.push.apply(parts, p); - - return parts; +// An option that is left out or null, or that is NaN, gets its default. Every +// comparison against NaN is false, so a NaN bound would never be reached: +// `{ maxSteps: NaN }` let 15KB of input block the event loop for 16 seconds, +// and `{ maxDepth: NaN }` overflowed the stack again (CVE-2026-102278). Pass +// `Infinity` to lift a bound. +function bound(value, fallback) { + return value == null || isNaN(value) ? fallback : value } function expandTop(str, options) { - if (!str) - return []; + if (!str) return [] - options = options || {}; - var max = options.max == null ? EXPANSION_MAX : options.max; - var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength; + options = options || {} + var max = bound(options.max, EXPANSION_MAX) + var maxLength = bound(options.maxLength, EXPANSION_MAX_LENGTH) + var maxDepth = bound(options.maxDepth, EXPANSION_MAX_DEPTH) + var maxRewrites = bound(options.maxRewrites, EXPANSION_MAX_REWRITES) + var maxSteps = bound(options.maxSteps, EXPANSION_MAX_STEPS) // I don't know why Bash 4.3 does this, but it does. // Anything starting with {} will have the first two bytes preserved @@ -13652,35 +13822,45 @@ function expandTop(str, options) { // One could argue that this is a bug in Bash, but since the goal of // this module is to match Bash's rules, we escape a leading {} if (str.substr(0, 2) === '{}') { - str = '\\{\\}' + str.substr(2); + str = '\\{\\}' + str.substr(2) } - return expand(escapeBraces(str), max, maxLength, true).map(unescapeBraces); + return expand( + escapeBraces(str), + max, + maxLength, + maxDepth, + 0, + maxRewrites, + { remaining: maxSteps }, + true + ).map(unescapeBraces) } function identity(e) { - return e; + return e } function embrace(str) { - return '{' + str + '}'; + return '{' + str + '}' } function isPadded(el) { - return /^-?0\d/.test(el); + return /^-?0\d/.test(el) } function lte(i, y) { - return i <= y; + return i <= y } function gte(i, y) { - return i >= y; + return i >= y } // Build `{ acc[a] + pre + values[v] }` for every combination, capping the // number of results at `max` and the total number of characters at `maxLength`. // This is the one place output grows, so bounding it here keeps the single // accumulator - and therefore memory - flat regardless of how many brace groups -// are combined (CVE-2026-14257). +// are combined (CVE-2026-14257). Each result built is a step, since `max` and +// `maxLength` bound one combination, not how many brace groups are combined. // // `base[a]` is the length of the part of `acc[a]` that predates the current // empty-drop baseline (see `expand`). The matching baselines for the results @@ -13693,35 +13873,41 @@ function combine( max, maxLength, dropEmpties, - outBase + outBase, + budget ) { var out = [] var length = 0 - for (var a = 0; a < acc.length; a++) { - for (var v = 0; v < values.length; v++) { - if (out.length >= max) return out - var expansion = acc[a] + pre + values[v] - // Bash drops empty results at the top level. Skip them before they count - // against `max`, so `max` bounds the number of *kept* results. "Empty" - // means "adds nothing past the baseline", not "empty overall". - if (dropEmpties && expansion.length === base[a]) continue - if (length + expansion.length > maxLength) return out + // Bash drops empty results at the top level, and they don't count against + // `max`, so `max` bounds the number of *kept* results. "Empty" means "adds + // nothing past the baseline", not "empty overall", and only an `acc[a] + pre` + // that adds nothing can make one, so for those the empty values are skipped + // without being visited. Visiting them one at a time let a set of empties + // cost `acc.length * values.length` while keeping nothing. + var nonEmpty + outer: for (var a = 0; a < acc.length; a++) { + var prefix = acc[a] + pre + var vs = values + if (dropEmpties && prefix.length === base[a]) { + if (!nonEmpty) nonEmpty = values.filter(Boolean) + vs = nonEmpty + } + for (var v = 0; v < vs.length; v++) { + if (out.length >= max) break outer + var expansion = prefix + vs[v] + if (length + expansion.length > maxLength) break outer out.push(expansion) outBase.push(base[a]) length += expansion.length } } + budget.remaining -= out.length return out } // The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`) -// sequence body. -function expandSequence( - body, - isAlphaSequence, - max, - maxLength -) { +// sequence body, or `undefined` if the step budget runs out generating them. +function expandSequence(body, isAlphaSequence, max, maxLength, budget) { var n = body.split(/\.\./) var N = [] // A sequence body always splits into two or three parts, but the compiler @@ -13745,9 +13931,21 @@ function expandSequence( test = gte } var pad = n.some(isPadded) + // A padded value is built a character at a time to `width`, which the input + // sets, so it costs one step per character: 64KB of + // `('{' + '0'.repeat(100) + '..99999}').repeat(n)` took 7 seconds charged + // one step per value. + var cost = pad ? width : 1 var length = 0 for (var i = x; test(i, y) && N.length < max; i += incr) { + // Each value is a step. `max` and `maxLength` bound one sequence, but a + // chain of them still generated up to `max` values each, however few + // combining could keep. + budget.remaining -= cost + if (budget.remaining < 0) { + return undefined + } var c if (isAlphaSequence) { c = String.fromCharCode(i) @@ -13779,8 +13977,22 @@ function expand( str, max, maxLength, + maxDepth, + depth, + maxRewrites, + budget, isTop ) { + // An overdraft here makes the first scan refuse, so `str` stays literal. + budget.remaining -= CALL_STEPS + + // Too deeply nested to keep following: treat the rest as literal, the same + // way a group that cannot expand is already handled. Truncating rather than + // throwing keeps expansion total, matching `max` and `maxLength`. + if (depth > maxDepth) { + return [str] + } + // Consume the string's top-level brace groups left to right, threading a // running set of combined prefixes (`acc`). Expanding the tail iteratively - // rather than recursing on `m.post` once per group - keeps the native stack @@ -13801,20 +14013,58 @@ function expand( // `accBase[a]` records how much of `acc[a]` predates the current run; // `combine` treats an expansion as empty when it adds nothing past that. var accBase = [0] + // How many times the `{a},b}` rewrite below has restarted the scan. Each pass + // re-reads the whole string, so leaving this unbounded is quadratic. + var rewrites = 0 var dropEmpties = false var firstGroup = true + // `str` with its unmatched `{` masked, once a scan has run into them + var masked = str var nextBase for (;;) { - var m = balanced('{', '}', str); + var m = balancedWithBudget(str, masked, budget) - // No brace set left: the rest of the string is literal. + // No brace set left, or no step budget left to look for one: the rest of + // the string is literal. if (!m) { - return combine(acc, accBase, str, [''], max, maxLength, dropEmpties, []) + return combine( + acc, + accBase, + str, + [''], + max, + maxLength, + dropEmpties, + [], + budget + ) + } + if (m.unmatched) { + masked = maskUnmatchedOpens(masked, budget) } // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; + var pre = m.pre + + // This set and the rest of the string, literal: for a set that cannot + // expand, and for one the step budget runs out on. Once it is overdrawn, + // every set still being expanded, at every level, stays literal like this - + // otherwise each level above would go on combining, and wrapping and + // expanding again, results the budget was too small for. + var literal = function () { + return combine( + acc, + accBase, + pre + '{' + m.body + '}' + m.post, + [''], + max, + maxLength, + dropEmpties, + [], + budget + ) + } // For compatibility reasons, `${` is not eligible for brace expansion, and // on the 1.x line it suppresses expansion of the rest of the string too: @@ -13823,17 +14073,35 @@ function expand( // be a breaking change for 1.x consumers. Routed through `combine` so the // result is still bounded by `max` and `maxLength`. if (/\$$/.test(pre)) { - return combine(acc, accBase, str, [''], max, maxLength, dropEmpties, []) + return combine( + acc, + accBase, + str, + [''], + max, + maxLength, + dropEmpties, + [], + budget + ) } - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = m.body.indexOf(',') >= 0; + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body) + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test( + m.body + ) + var isSequence = isNumericSequence || isAlphaSequence + var isOptions = m.body.indexOf(',') >= 0 if (!isSequence && !isOptions) { // {a},b} - if (m.post.match(/,(?!,).*\}/)) { - str = m.pre + '{' + m.body + escClose + m.post; + if (rewrites < maxRewrites && commaSetFollows(m.post, budget)) { + rewrites++ + str = m.pre + '{' + m.body + escClose + m.post + // Taking a `}` away never gives an unmatched `{` a partner, so what + // is masked stays unmatched. The `{` it closed can be left without + // one, and the next scan masks it. + masked = + masked.slice(0, m.end) + escClose + masked.slice(m.end + 1) // The rewritten string is expanded as if it were a fresh top-level one, // so start a new empty-drop run: anchor the baseline at what `acc` // holds now, and let the next expanding group decide whether to drop. @@ -13847,16 +14115,7 @@ function expand( continue } // Nothing here expands, so the whole remaining string is literal. - return combine( - acc, - accBase, - pre + '{' + m.body + '}' + m.post, - [''], - max, - maxLength, - dropEmpties, - [] - ) + return literal() } if (firstGroup) { @@ -13864,19 +14123,45 @@ function expand( firstGroup = false } - var values; + var values if (isSequence) { - values = expandSequence(m.body, isAlphaSequence, max, maxLength); + values = expandSequence( + m.body, + isAlphaSequence, + max, + maxLength, + budget + ) + if (!values) { + return literal() + } } else { - var n = parseCommaParts(m.body); + var n = parseCommaParts(m.body, budget) + // The step budget ran out partway through the set. + if (!n) { + return literal() + } if (n.length === 1 && n[0] !== undefined) { // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], max, maxLength, false).map(embrace); + n = expand( + n[0], + max, + maxLength, + maxDepth, + depth + 1, + maxRewrites, + budget, + false + ).map(embrace) + // The step budget ran out expanding the set's only part. + if (budget.remaining < 0) { + return literal() + } //XXX is this necessary? Can't seem to hit it in tests. /* c8 ignore start */ if (n.length === 1) { nextBase = [] - acc = combine( + var single = combine( acc, accBase, pre + n[0], @@ -13884,11 +14169,17 @@ function expand( max, maxLength, dropEmpties && !m.post.length, - nextBase + nextBase, + budget ) + if (budget.remaining < 0) { + return literal() + } + acc = single accBase = nextBase if (!m.post.length) break str = m.post + masked = masked.slice(m.end + 1) continue } /* c8 ignore stop */ @@ -13910,11 +14201,27 @@ function expand( values = [] var valuesLength = 0 outer: for (var j = 0; j < n.length; j++) { - var expanded = expand(n[j], max, maxLength, false) + var expanded = expand( + n[j], + max, + maxLength, + maxDepth, + depth + 1, + maxRewrites, + budget, + false + ) + // The step budget ran out expanding a member. + if (budget.remaining < 0) { + return literal() + } for (var k = 0; k < expanded.length; k++) { var v = expanded[k] if (dropsEmpties && !v) continue - if (values.length >= max || valuesLength + v.length > maxLength) { + if ( + values.length >= max || + valuesLength + v.length > maxLength + ) { break outer } values.push(v) @@ -13924,7 +14231,7 @@ function expand( } nextBase = [] - acc = combine( + var next = combine( acc, accBase, pre, @@ -13932,11 +14239,18 @@ function expand( max, maxLength, dropEmpties && !m.post.length, - nextBase + nextBase, + budget ) + // The step budget ran out combining the set's values in. + if (budget.remaining < 0) { + return literal() + } + acc = next accBase = nextBase if (!m.post.length) break str = m.post + masked = masked.slice(m.end + 1) } return acc @@ -90453,7 +90767,7 @@ function randomUUID() { /***/ 74577: /***/ ((module) => { -(()=>{"use strict";var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>Oe,XMLParser:()=>re,XMLValidator:()=>je});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 r(t,e){const i=[];let n=e.exec(t);for(;n;){const r=[];r.startIndex=e.lastIndex-n[0].length;const s=n.length;for(let t=0;t"!==t[s]&&" "!==t[s]&&"\t"!==t[s]&&"\n"!==t[s]&&"\r"!==t[s];s++)l+=t[s];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),s--),!E(l)){let e;return e=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",y("InvalidTag",e,w(t,s))}const p=g(t,s);if(!1===p)return y("InvalidAttr","Attributes for '"+l+"' have open quote.",w(t,s));let u=p.value;if(s=p.index,"/"===u[u.length-1]){const i=s-u.length;u=u.substring(0,u.length-1);const r=x(u,e);if(!0!==r)return y(r.err.code,r.err.msg,w(t,i+r.err.line));n=!0}else if(a){if(!p.tagClosed)return y("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",w(t,s));if(u.trim().length>0)return y("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",w(t,o));if(0===i.length)return y("InvalidTag","Closing tag '"+l+"' has not been opened.",w(t,o));{const e=i.pop();if(l!==e.tagName){let i=w(t,e.tagStartPos);return y("InvalidTag","Expected closing tag '"+e.tagName+"' (opened in line "+i.line+", col "+i.col+") instead of closing tag '"+l+"'.",w(t,o))}0==i.length&&(r=!0)}}else{const a=x(u,e);if(!0!==a)return y(a.err.code,a.err.msg,w(t,s-u.length+a.err.line));if(!0===r)return y("InvalidXml","Multiple possible root nodes found.",w(t,s));-1!==e.unpairedTags.indexOf(l)||i.push({tagName:l,tagStartPos:o}),n=!0}for(s++;s0)||y("InvalidXml","Invalid '"+JSON.stringify(i.map(t=>t.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):y("InvalidXml","Start tag expected.",1)}function c(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function h(t,e){const i=e;for(;e5&&"xml"===n)return y("InvalidXml","XML declaration allowed only at the start of the document.",w(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}continue}return e}function d(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){let i=1;for(e+=8;e"===t[e]&&(i--,0===i))break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e"===t[e+2]){e+=2;break}return e}const u='"',f="'";function g(t,e){let i="",n="",r=!1;for(;e"===t[e]&&""===n){r=!0;break}i+=t[e]}return""===n&&{value:i,index:e,tagClosed:r}}const m=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function x(t,e){const i=r(t,m),n={};for(let t=0;to.includes(t)?"__"+t:t,A={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,i){return t},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:S};function T(t,e){if("string"!=typeof t)return;const i=t.toLowerCase();if(o.some(t=>i===t.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`);if(a.some(t=>i===t.toLowerCase()))throw new Error(`[SECURITY] Invalid ${e}: "${t}" is a reserved JavaScript keyword that could cause prototype pollution`)}function _(t,e){return"boolean"==typeof t?{enabled:t,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:"object"==typeof t&&null!==t?{enabled:!1!==t.enabled,maxEntitySize:Math.max(1,t.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,t.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,t.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,t.maxExpandedLength??1e5),maxEntityCount:Math.max(1,t.maxEntityCount??1e3),allowedTags:t.allowedTags??null,tagFilter:t.tagFilter??null,appliesTo:t.appliesTo??"all"}:_(!0)}const C=function(t){const e=Object.assign({},A,t),i=[{value:e.attributeNamePrefix,name:"attributeNamePrefix"},{value:e.attributesGroupName,name:"attributesGroupName"},{value:e.textNodeName,name:"textNodeName"},{value:e.cdataPropName,name:"cdataPropName"},{value:e.commentPropName,name:"commentPropName"}];for(const{value:t,name:e}of i)t&&T(t,e);return null===e.onDangerousProperty&&(e.onDangerousProperty=S),e.processEntities=_(e.processEntities,e.htmlEntities),e.unpairedTagsSet=new Set(e.unpairedTags),e.stopNodes&&Array.isArray(e.stopNodes)&&(e.stopNodes=e.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),e};let $;$="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class P{constructor(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][$]={startIndex:e})}static getMetaDataSymbol(){return $}}const O=":A-Za-z_À-ÖØ-öø-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�",j=":A-Za-z_À-˿Ͱ-ͽͿ-҆҈-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿",I=j+"\\-\\.\\d·̀-ͯ҇‿-⁀",k=(t,e,i="")=>{const n=`[${t.replace(":","")}][${e.replace(":","")}]*`;return{name:new RegExp(`^[${t}][${e}]*$`,i),ncName:new RegExp(`^${n}$`,i),qName:new RegExp(`^${n}(?::${n})?$`,i),nmToken:new RegExp(`^[${e}]+$`,i),nmTokens:new RegExp(`^[${e}]+(?:\\s+[${e}]+)*$`,i)}},L=k(O,O+"\\-\\.\\d·̀-ͯ‿-⁀"),D=k(j,I,"u"),R=":A-Za-z_",M=k(R,R+"\\-\\.\\d"),V=(t,{xmlVersion:e="1.0",asciiOnly:i=!1}={})=>((t="1.0",e=!1)=>e?M:"1.1"===t?D:L)(e,i).qName.test(t);class q{constructor(t,e){this.suppressValidationErr=!t,this.options=t,this.xmlVersion=e||1}setXmlVersion(t=1){this.xmlVersion=t}readDocType(t,e){const i=Object.create(null);let n=0;if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let r=1,s=!1,o=!1,a="";for(;e"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=!1,r--):r--,0===r)break}else"["===t[e]?s=!0:a+=t[e];else{if(s&&U(t,"!ENTITY",e)){let r,s;if(e+=7,[r,s,e]=this.readEntityExp(t,e+1,this.suppressValidationErr),-1===s.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&n>=this.options.maxEntityCount)throw new Error(`Entity count (${n+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);i[r]=s,n++}}else if(s&&U(t,"!ELEMENT",e)){e+=8;const{index:i}=this.readElementExp(t,e+1);e=i}else if(s&&U(t,"!ATTLIST",e))e+=8;else if(s&&U(t,"!NOTATION",e)){e+=9;const{index:i}=this.readNotationExp(t,e+1,this.suppressValidationErr);e=i}else{if(!U(t,"!--",e))throw new Error("Invalid DOCTYPE");o=!0}r++,a=""}if(0!==r)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:e}}readEntityExp(t,e){const i=e=F(t,e);for(;ethis.options.maxEntitySize)throw new Error(`Entity "${n}" size (${r.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[n,r,--e]}readNotationExp(t,e){const i=e=F(t,e);for(;e{for(;e=48&&r<=57||45===r))if(r=55296&&r<=56319){if(n+1=56320&&e<=57343){const t=65536+(r-55296<<10)+(e-56320);if(X.has(t)){i=n;break}}}}else if(255!==z[r-W]||Y.has(r)){i=n;break}}if(-1===i)return t;const n=[];i>0&&n.push(t.slice(0,i));for(let r=i;r=48&&i<=57||45===i){n.push(t[r]);continue}if(i=55296&&i<=56319){if(r+1=56320&&e<=57343){const t=65536+(i-55296<<10)+(e-56320),s=X.get(t);if(void 0!==s){n.push(String.fromCharCode(s+48)),r++;continue}}}n.push(t[r]);continue}if(Y.has(i)){n.push("-");continue}const s=z[i-W];n.push(255!==s?String.fromCharCode(s+48):t[r])}return n.join("")}(i),"0"===i))return 0;if(e.hex&&H.test(i))return it(i,16);if(e.binary&&Q.test(i))return it(i,2);if(e.octal&&J.test(i))return it(i,8);if(isFinite(i)){if(i.includes("e")||i.includes("E"))return function(t,e,i){if(!i.eNotation)return t;const n=e.match(et);if(n){let r=n[1]||"";const s=-1===n[3].indexOf("e")?"E":"e",o=n[2],a=r?t[o.length+1]===s:t[o.length]===s;return o.length>1&&a?t:(1!==o.length||!n[3].startsWith(`.${s}`)&&n[3][0]!==s)&&o.length>0?i.leadingZeros&&!a?(e=(n[1]||"")+n[3],Number(e)):t:Number(e)}return t}(t,i,e);{const r=Z.exec(i);if(r){const s=r[1]||"",o=r[2];let a=(n=r[3])&&-1!==n.indexOf(".")?("."===(n=n.replace(/0+$/,""))?n="0":"."===n[0]?n="0"+n:"."===n[n.length-1]&&(n=n.substring(0,n.length-1)),n):n;const l=s?"."===t[o.length+1]:"."===t[o.length];if(!e.leadingZeros&&(o.length>1||1===o.length&&!l))return t;{const n=Number(i),r=String(n);if(0===n)return n;if(-1!==r.search(/[eE]/))return e.eNotation?n:t;if(-1!==i.indexOf("."))return"0"===r||r===a||r===`${s}${a}`?n:t;let l=o?a:i;return o?l===r||s+l===r?n:t:l===r||l===s+r?n:t}}return t}}var n;return function(t,e,i){const n=e===1/0;switch(i.infinity.toLowerCase()){case"null":return null;case"infinity":return e;case"string":return n?"Infinity":"-Infinity";default:return t}}(t,Number(i),e)}const et=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function it(t,e){const i=t.trim();if(2!==e&&8!==e||(t=i.substring(2)),parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}class nt{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const i=e[e.length-1];return void 0!==i.values&&t in i.values}getAnyParentAttr(t){return this._matcher.getAnyParentAttr(t)}hasAnyParentAttr(t){return this._matcher.hasAnyParentAttr(t)}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class rt{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new nt(this),this._keptAttrs=[]}push(t,e=null,i=null,n=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const r=this.path.length;let s=this.siblingStacks[r];s||(s={counts:new Map,total:0},this.siblingStacks[r]=s);const o=i?`${i}:${t}`:t,a=s.counts.get(o)||0,l=s.total;s.counts.set(o,a+1),s.total++;const p={tag:t,position:l,counter:a};null!=i&&(p.namespace=i),null!=e&&(p.values=e),this.path.push(p);const c=this.path.length,h=null!==n?n.keep:null;if(null!=h&&h.length>0&&e)for(let t=0;tthis.path.length+1&&(this.siblingStacks.length=this.path.length+1);const e=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=e;)this._keptAttrs.pop();return t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}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(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getAnyParentAttr(t){const e=this._keptAttrs;for(let i=e.length-1;i>=0;i--)if(e[i].name===t)return e[i].value}hasAnyParentAttr(t){const e=this._keptAttrs;for(let i=e.length-1;i>=0;i--)if(e[i].name===t)return!0;return!1}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(t,e=!0){const i=t||this.separator;if(i===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e=0&&e>=0;){const n=t[i];if("deep-wildcard"===n.type){if(i--,i<0)return!0;const n=t[i];let r=!1;for(let t=e;t>=0;t--)if(this._matchSegment(n,this.path[t],t===this.path.length-1)){e=t-1,i--,r=!0;break}if(!r)return!1}else{if(!this._matchSegment(n,this.path[e],e===this.path.length-1))return!1;e--,i--}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!i)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!i)return!1;const n=e.counter??0;if("first"===t.position&&0!==n)return!1;if("odd"===t.position&&n%2!=1)return!1;if("even"===t.position&&n%2!=0)return!1;if("nth"===t.position&&n!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>t?{counts:new Map(t.counts),total:t.total}:t),keptAttrs:this._keptAttrs.map(t=>({...t}))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>t?{counts:new Map(t.counts),total:t.total}:t),this._keptAttrs=(t.keptAttrs||[]).map(t=>({...t}))}readOnly(){return this._view}}class st{constructor(t,e={},i){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=i,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let i=0,n="";for(;i",lt:"<",quot:'"'},pt={nbsp:" ",copy:"©",reg:"®",trade:"™",mdash:"—",ndash:"–",hellip:"…",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",para:"¶",sect:"§",deg:"°",frac12:"½",frac14:"¼",frac34:"¾"},ct=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),ht=new Set("!?\\\\/[]$%{}^&*()<>|+");function dt(t){if("#"===t[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t}"`);for(const e of t)if(ht.has(e))throw new Error(`[EntityReplacer] Invalid character '${e}' in entity name: "${t}"`);return t}function ut(...t){const e=Object.create(null);for(const i of t)if(i)for(const t of Object.keys(i)){const n=i[t];if("string"==typeof n)e[t]=n;else if(n&&"object"==typeof n&&void 0!==n.val){const i=n.val;"string"==typeof i&&(e[t]=i)}}return e}const ft="external",gt="base",mt="all",xt=Object.freeze({allow:0,leave:1,remove:2,throw:3}),bt=new Set([9,10,13]);class yt{constructor(t={}){var e;this._limit=t.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck="function"==typeof t.postCheck?t.postCheck:t=>t,this._limitTiers=(e=this._limit.applyLimitsTo??ft)&&e!==ft?e===mt?new Set([mt]):e===gt?new Set([gt]):Array.isArray(e)?new Set(e):new Set([ft]):new Set([ft]),this._numericAllowed=t.numericAllowed??!0,this._baseMap=ut(lt,t.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(t.remove&&Array.isArray(t.remove)?t.remove:[]),this._leaveSet=new Set(t.leave&&Array.isArray(t.leave)?t.leave:[]);const i=function(t){if(!t)return{xmlVersion:1,onLevel:xt.allow,nullLevel:xt.remove};const e=1.1===t.xmlVersion?1.1:1,i=xt[t.onNCR]??xt.allow,n=xt[t.nullNCR]??xt.remove;return{xmlVersion:e,onLevel:i,nullLevel:Math.max(n,xt.remove)}}(t.ncr);this._ncrXmlVersion=i.xmlVersion,this._ncrOnLevel=i.onLevel,this._ncrNullLevel=i.nullLevel,this._onExternalEntity="function"==typeof t.onExternalEntity?t.onExternalEntity:null,this._onInputEntity="function"==typeof t.onInputEntity?t.onInputEntity:null}_applyRegistrationHook(t,e,i,n){if(!t)return!0;const r=t(e,i);if(r===ct.BLOCK)return!1;if(r===ct.THROW)throw new Error(`[EntityDecoder] Registration of ${n} entity "&${e};" was rejected by hook`);return!0}setExternalEntities(t){if(t)for(const e of Object.keys(t))dt(e);if(!this._onExternalEntity)return void(this._externalMap=ut(t));const e=ut(t),i=Object.create(null);for(const[t,n]of Object.entries(e))this._applyRegistrationHook(this._onExternalEntity,t,n,"external")&&(i[t]=n);this._externalMap=i}addExternalEntity(t,e){dt(t),"string"==typeof e&&-1===e.indexOf("&")&&this._applyRegistrationHook(this._onExternalEntity,t,e,"external")&&(this._externalMap[t]=e)}addInputEntities(t){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity)return void(this._inputMap=ut(t));const e=ut(t),i=Object.create(null);for(const[t,n]of Object.entries(e))this._applyRegistrationHook(this._onInputEntity,t,n,"input")&&(i[t]=n);this._inputMap=i}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(t){this._ncrXmlVersion=1.1===t?1.1:1}decode(t){if("string"!=typeof t||0===t.length)return t;if(-1===t.indexOf("&"))return t;const e=t,i=[],n=t.length;let r=0,s=0;const o=this._maxTotalExpansions>0,a=this._maxExpandedLength>0,l=o||a;for(;s=n||59!==t.charCodeAt(e)){s++;continue}const p=t.slice(s+1,e);if(0===p.length){s++;continue}let c,h;if(this._removeSet.has(p))c="",void 0===h&&(h=ft);else{if(this._leaveSet.has(p)){s++;continue}if(35===p.charCodeAt(0)){const t=this._resolveNCR(p);if(void 0===t){s++;continue}c=t,h=gt}else{const t=this._resolveName(p);c=t?.value,h=t?.tier}}if(void 0!==c){if(s>r&&i.push(t.slice(r,s)),i.push(c),r=e+1,s=r,l&&this._tierCounts(h)){if(o&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(a){const t=c.length-(p.length+2);if(t>0&&(this._expandedLength+=t,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else s++}r=55296&&t<=57343||1===this._ncrXmlVersion&&t>=1&&t<=31&&!bt.has(t)?xt.remove:-1}_applyNCRAction(t,e,i){switch(t){case xt.allow:return String.fromCodePoint(i);case xt.remove:return"";case xt.leave:return;case xt.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e}; (U+${i.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(i)}}_resolveNCR(t){const e=t.charCodeAt(1);let i;if(i=120===e||88===e?parseInt(t.slice(2),16):parseInt(t.slice(1),10),Number.isNaN(i)||i<0||i>1114111)return;const n=this._classifyNCR(i);if(!this._numericAllowed&&n/]/i},{id:"html-script-close",description:"<\/script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI — can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI — can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded