diff --git a/.github/workflows/binstall.yml b/.github/workflows/binstall.yml index 60a53dad..7b8303b0 100644 --- a/.github/workflows/binstall.yml +++ b/.github/workflows/binstall.yml @@ -25,7 +25,7 @@ jobs: - run: rustup toolchain install stable --profile minimal --no-self-update - - uses: cargo-bins/cargo-binstall@e00d2c94cc0067b77737821097a62d91c0301baa # v1.21.1 + - uses: cargo-bins/cargo-binstall@3be4ad2b146f3302f92e5956c54fedbb6ae8cccc # v1.25.3 - uses: ./ diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 04481d53..f9f6b972 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -23,7 +23,7 @@ jobs: persist-credentials: false - name: Setup Node.js 24.x - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24.x cache: npm @@ -43,7 +43,7 @@ jobs: fi id: diff - - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 if: ${{ failure() && steps.diff.conclusion == 'failure' }} with: name: dist diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a3b7800d..f863d809 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -25,7 +25,7 @@ jobs: - run: rustup toolchain install stable --profile minimal --component llvm-tools-preview --no-self-update - - uses: taiki-e/install-action@6a1bd70eaac3c8bdf093356838d7ee09fda951cf # v2.85.5 + - uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29 with: tool: cargo-llvm-cov diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 3c39b536..2828065d 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -37,7 +37,7 @@ jobs: fi - name: Setup node if necessary if: steps.npm.outputs.changed != '' - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24.x cache: npm diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index b1cce29b..5e64dd6e 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -20,7 +20,7 @@ jobs: with: persist-credentials: false - - uses: cachix/install-nix-action@630ae543ea3a38a9a4166f03376c02c50f408342 # v31.11.0 + - uses: cachix/install-nix-action@448cde739abec1eaf0646249e3d25bb8d9bc7702 # v31.11.2 - uses: ./ with: diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index 837a546f..6330fb28 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -21,4 +21,4 @@ jobs: persist-credentials: false - name: Run zizmor 🌈 - uses: zizmorcore/zizmor-action@6fc4b006235f201fdab3722e17240ab420d580e5 # v0.6.1 + uses: zizmorcore/zizmor-action@85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e # v0.7.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index b2e242d4..54e946ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 2.9.3 + +- Fix timestamp based pruning +- Add missing `await`s +- Do not emit warning on missing `rustup` + ## 2.9.2 - Fix `credentials.toml` cleanup diff --git a/dist/cache-DC26rUaF.js b/dist/cache-BzPKClMA.js similarity index 84% rename from dist/cache-DC26rUaF.js rename to dist/cache-BzPKClMA.js index d700b95b..9c7a3dca 100644 --- a/dist/cache-DC26rUaF.js +++ b/dist/cache-BzPKClMA.js @@ -1,4 +1,4 @@ -import { v as commonjsGlobal, x as requireTunnel, y as getDefaultExportFromCjs, z as getAugmentedNamespace } from './cleanup-BWEbZ6YT.js'; +import { x as commonjsGlobal, y as requireTunnel, z as getDefaultExportFromCjs, A as getAugmentedNamespace } from './cleanup-e3M0pm4f.js'; import os__default from 'os'; import crypto__default from 'crypto'; import fs__default from 'fs'; @@ -704,12 +704,12 @@ function requireErrors$2 () { return errors$2; } -var constants$f; -var hasRequiredConstants$f; +var constants$g; +var hasRequiredConstants$g; -function requireConstants$f () { - if (hasRequiredConstants$f) return constants$f; - hasRequiredConstants$f = 1; +function requireConstants$g () { + if (hasRequiredConstants$g) return constants$g; + hasRequiredConstants$g = 1; /** @type {Record} */ const headerNameLowerCasedRecord = {}; @@ -823,11 +823,11 @@ function requireConstants$f () { // Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. Object.setPrototypeOf(headerNameLowerCasedRecord, null); - constants$f = { + constants$g = { wellknownHeaderNames, headerNameLowerCasedRecord }; - return constants$f; + return constants$g; } var util$i; @@ -846,7 +846,7 @@ function requireUtil$i () { const { Blob } = require$$0__default; const nodeUtil = require$$0__default$1; const { stringify } = require$$1$1; - const { headerNameLowerCasedRecord } = requireConstants$f(); + const { headerNameLowerCasedRecord } = requireConstants$g(); const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(v => Number(v)); @@ -3092,12 +3092,12 @@ function requireMain () { return main$2.exports; } -var constants$e; -var hasRequiredConstants$e; +var constants$f; +var hasRequiredConstants$f; -function requireConstants$e () { - if (hasRequiredConstants$e) return constants$e; - hasRequiredConstants$e = 1; +function requireConstants$f () { + if (hasRequiredConstants$f) return constants$f; + hasRequiredConstants$f = 1; const { MessageChannel, receiveMessageOnPort } = require$$0$9; @@ -3223,7 +3223,7 @@ function requireConstants$e () { return receiveMessageOnPort(channel.port2).message }; - constants$e = { + constants$f = { DOMException, structuredClone, subresource, @@ -3248,7 +3248,7 @@ function requireConstants$e () { forbiddenMethodsSet, referrerPolicySet }; - return constants$e; + return constants$f; } var global$4; @@ -3306,7 +3306,7 @@ function requireUtil$h () { if (hasRequiredUtil$h) return util$h; hasRequiredUtil$h = 1; - const { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } = requireConstants$e(); + const { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } = requireConstants$f(); const { getGlobalOrigin } = requireGlobal$3(); const { performance } = require$$2$2; const { isBlobLike, toUSVString, ReadableStreamFrom } = requireUtil$i(); @@ -5758,12 +5758,12 @@ function requireDataURL$1 () { return dataURL$1; } -var file$3; -var hasRequiredFile$3; +var file$4; +var hasRequiredFile$4; -function requireFile$3 () { - if (hasRequiredFile$3) return file$3; - hasRequiredFile$3 = 1; +function requireFile$4 () { + if (hasRequiredFile$4) return file$4; + hasRequiredFile$4 = 1; const { Blob, File: NativeFile } = require$$0__default; const { types } = require$$0__default$1; @@ -6106,8 +6106,8 @@ function requireFile$3 () { ) } - file$3 = { File, FileLike, isFileLike }; - return file$3; + file$4 = { File, FileLike, isFileLike }; + return file$4; } var formdata$1; @@ -6119,7 +6119,7 @@ function requireFormdata$1 () { const { isBlobLike, toUSVString, makeIterator } = requireUtil$h(); const { kState } = requireSymbols$8(); - const { File: UndiciFile, FileLike, isFileLike } = requireFile$3(); + const { File: UndiciFile, FileLike, isFileLike } = requireFile$4(); const { webidl } = requireWebidl$1(); const { Blob, File: NativeFile } = require$$0__default; @@ -6403,13 +6403,13 @@ function requireBody$1 () { const { FormData } = requireFormdata$1(); const { kState } = requireSymbols$8(); const { webidl } = requireWebidl$1(); - const { DOMException, structuredClone } = requireConstants$e(); + const { DOMException, structuredClone } = requireConstants$f(); const { Blob, File: NativeFile } = require$$0__default; const { kBodyUsed } = requireSymbols$9(); const assert$1 = assert; const { isErrored } = requireUtil$i(); const { isUint8Array, isArrayBuffer } = require$$5; - const { File: UndiciFile } = requireFile$3(); + const { File: UndiciFile } = requireFile$4(); const { parseMIMEType, serializeAMimeType } = requireDataURL$1(); let random; @@ -7935,7 +7935,7 @@ function requireConnect$1 () { return connect$1; } -var constants$d = {}; +var constants$e = {}; var utils$6 = {}; @@ -7961,11 +7961,11 @@ function requireUtils$6 () { return utils$6; } -var hasRequiredConstants$d; +var hasRequiredConstants$e; -function requireConstants$d () { - if (hasRequiredConstants$d) return constants$d; - hasRequiredConstants$d = 1; +function requireConstants$e () { + if (hasRequiredConstants$e) return constants$e; + hasRequiredConstants$e = 1; (function (exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.SPECIAL_HEADERS = exports.HEADER_STATE = exports.MINOR = exports.MAJOR = exports.CONNECTION_TOKEN_CHARS = exports.HEADER_CHARS = exports.TOKEN = exports.STRICT_TOKEN = exports.HEX = exports.URL_CHAR = exports.STRICT_URL_CHAR = exports.USERINFO_CHARS = exports.MARK = exports.ALPHANUM = exports.NUM = exports.HEX_MAP = exports.NUM_MAP = exports.ALPHA = exports.FINISH = exports.H_METHOD_MAP = exports.METHOD_MAP = exports.METHODS_RTSP = exports.METHODS_ICE = exports.METHODS_HTTP = exports.METHODS = exports.LENIENT_FLAGS = exports.FLAGS = exports.TYPE = exports.ERROR = void 0; @@ -8238,8 +8238,8 @@ function requireConstants$d () { 'upgrade': HEADER_STATE.UPGRADE, }; - } (constants$d)); - return constants$d; + } (constants$e)); + return constants$e; } var RedirectHandler_1$1; @@ -8989,7 +8989,7 @@ function requireClient$1 () { resume(client); } - const constants = requireConstants$d(); + const constants = requireConstants$e(); const createRedirectInterceptor = requireRedirectInterceptor$1(); const EMPTY_BUF = Buffer.alloc(0); @@ -15315,7 +15315,7 @@ function requireResponse$2 () { redirectStatusSet, nullBodyStatus, DOMException - } = requireConstants$e(); + } = requireConstants$f(); const { kState, kHeaders, kGuard, kRealm } = requireSymbols$8(); const { webidl } = requireWebidl$1(); const { FormData } = requireFormdata$1(); @@ -15899,7 +15899,7 @@ function requireRequest$2 () { requestCredentials, requestCache, requestDuplex - } = requireConstants$e(); + } = requireConstants$f(); const { kEnumerableProperty } = util; const { kHeaders, kSignal, kState, kGuard, kRealm } = requireSymbols$8(); const { webidl } = requireWebidl$1(); @@ -16881,7 +16881,7 @@ function requireFetch$1 () { requestBodyHeader, subresourceSet, DOMException - } = requireConstants$e(); + } = requireConstants$f(); const { kHeadersList } = requireSymbols$9(); const EE = require$$0__default$3; const { Readable, pipeline } = require$$0__default$2; @@ -19322,7 +19322,7 @@ function requireUtil$f () { } = requireSymbols$7(); const { ProgressEvent } = requireProgressevent$1(); const { getEncoding } = requireEncoding$1(); - const { DOMException } = requireConstants$e(); + const { DOMException } = requireConstants$f(); const { serializeAMimeType, parseMIMEType } = requireDataURL$1(); const { types } = require$$0__default$1; const { StringDecoder } = require$$6; @@ -21126,12 +21126,12 @@ function requireCachestorage$1 () { return cachestorage$1; } -var constants$c; -var hasRequiredConstants$c; +var constants$d; +var hasRequiredConstants$d; -function requireConstants$c () { - if (hasRequiredConstants$c) return constants$c; - hasRequiredConstants$c = 1; +function requireConstants$d () { + if (hasRequiredConstants$d) return constants$d; + hasRequiredConstants$d = 1; // https://wicg.github.io/cookie-store/#cookie-maximum-attribute-value-size const maxAttributeValueSize = 1024; @@ -21139,11 +21139,11 @@ function requireConstants$c () { // https://wicg.github.io/cookie-store/#cookie-maximum-name-value-pair-size const maxNameValuePairSize = 4096; - constants$c = { + constants$d = { maxAttributeValueSize, maxNameValuePairSize }; - return constants$c; + return constants$d; } var util$d; @@ -21435,7 +21435,7 @@ function requireParse$2 () { if (hasRequiredParse$2) return parse$5; hasRequiredParse$2 = 1; - const { maxNameValuePairSize, maxAttributeValueSize } = requireConstants$c(); + const { maxNameValuePairSize, maxAttributeValueSize } = requireConstants$d(); const { isCTLExcludingHtab } = requireUtil$d(); const { collectASequenceOfCodePointsFast } = requireDataURL$1(); const assert$1 = assert; @@ -21944,12 +21944,12 @@ function requireCookies$1 () { return cookies$1; } -var constants$b; -var hasRequiredConstants$b; +var constants$c; +var hasRequiredConstants$c; -function requireConstants$b () { - if (hasRequiredConstants$b) return constants$b; - hasRequiredConstants$b = 1; +function requireConstants$c () { + if (hasRequiredConstants$c) return constants$c; + hasRequiredConstants$c = 1; // This is a Globally Unique Identifier unique used // to validate that the endpoint accepts websocket @@ -21991,7 +21991,7 @@ function requireConstants$b () { const emptyBuffer = Buffer.allocUnsafe(0); - constants$b = { + constants$c = { uid, staticPropertyDescriptors, states, @@ -22000,7 +22000,7 @@ function requireConstants$b () { parserStates, emptyBuffer }; - return constants$b; + return constants$c; } var symbols$5; @@ -22342,7 +22342,7 @@ function requireUtil$c () { hasRequiredUtil$c = 1; const { kReadyState, kController, kResponse, kBinaryType, kWebSocketURL } = requireSymbols$5(); - const { states, opcodes } = requireConstants$b(); + const { states, opcodes } = requireConstants$c(); const { MessageEvent, ErrorEvent } = requireEvents$1(); /* globals Blob */ @@ -22550,7 +22550,7 @@ function requireConnection$1 () { hasRequiredConnection$1 = 1; const diagnosticsChannel = require$$0$a; - const { uid, states } = requireConstants$b(); + const { uid, states } = requireConstants$c(); const { kReadyState, kSentClose, @@ -22848,7 +22848,7 @@ function requireFrame$1 () { if (hasRequiredFrame$1) return frame$1; hasRequiredFrame$1 = 1; - const { maxUnsigned16Bit } = requireConstants$b(); + const { maxUnsigned16Bit } = requireConstants$c(); /** @type {import('crypto')} */ let crypto; @@ -22931,7 +22931,7 @@ function requireReceiver$1 () { const { Writable } = require$$0__default$2; const diagnosticsChannel = require$$0$a; - const { parserStates, opcodes, states, emptyBuffer } = requireConstants$b(); + const { parserStates, opcodes, states, emptyBuffer } = requireConstants$c(); const { kReadyState, kSentClose, kResponse, kReceivedClose } = requireSymbols$5(); const { isValidStatusCode, failWebsocketConnection, websocketMessageReceived } = requireUtil$c(); const { WebsocketFrameSend } = requireFrame$1(); @@ -23282,10 +23282,10 @@ function requireWebsocket$1 () { hasRequiredWebsocket$1 = 1; const { webidl } = requireWebidl$1(); - const { DOMException } = requireConstants$e(); + const { DOMException } = requireConstants$f(); const { URLSerializer } = requireDataURL$1(); const { getGlobalOrigin } = requireGlobal$3(); - const { staticPropertyDescriptors, states, opcodes, emptyBuffer } = requireConstants$b(); + const { staticPropertyDescriptors, states, opcodes, emptyBuffer } = requireConstants$c(); const { kWebSocketURL, kReadyState, @@ -24045,7 +24045,7 @@ function requireUndici$1 () { undici$1.Response = requireResponse$2().Response; undici$1.Request = requireRequest$2().Request; undici$1.FormData = requireFormdata$1().FormData; - undici$1.File = requireFile$3().File; + undici$1.File = requireFile$4().File; undici$1.FileReader = requireFilereader$1().FileReader; const { setGlobalOrigin, getGlobalOrigin } = requireGlobal$3(); @@ -27391,28 +27391,6 @@ function requireInternalPatternHelper () { var internalPattern = {}; -var concatMap; -var hasRequiredConcatMap; - -function requireConcatMap () { - if (hasRequiredConcatMap) return concatMap; - hasRequiredConcatMap = 1; - concatMap = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; - }; - - var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; - }; - return concatMap; -} - var balancedMatch; var hasRequiredBalancedMatch; @@ -27489,7 +27467,6 @@ var hasRequiredBraceExpansion; function requireBraceExpansion () { if (hasRequiredBraceExpansion) return braceExpansion; hasRequiredBraceExpansion = 1; - var concatMap = requireConcatMap(); var balanced = requireBalancedMatch(); braceExpansion = expandTop; @@ -27500,6 +27477,40 @@ function requireBraceExpansion () { var escComma = '\0COMMA'+Math.random()+'\0'; var escPeriod = '\0PERIOD'+Math.random()+'\0'; + var EXPANSION_MAX = 100000; + + // `EXPANSION_MAX` caps the *number* of expansions, but not their length. An + // input like `'{a,b}'.repeat(1500)` stays under that count - its output is + // truncated to 100k results - while making every result ~1500 characters + // long. The result set, and the intermediate arrays built while combining + // brace sets, then grow large enough to exhaust memory and crash the process + // (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of + // characters the accumulator may hold at any point, so memory stays flat no + // matter how many brace groups are chained. The limit sits well above any + // realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M + // 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; + function numeric(str) { return parseInt(str, 10) == str ? parseInt(str, 10) @@ -27523,34 +27534,54 @@ function requireBraceExpansion () { } + // 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]); + } + } + // 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 ['']; - var parts = []; - var m = balanced('{', '}', str); - if (!m) - return str.split(','); + // 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 = ''; - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); + for (;;) { + var m = balanced('{', '}', str); - 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; + } - parts.push.apply(parts, p); + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); - return parts; + 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; + } } function expandTop(str, options) { @@ -27558,7 +27589,10 @@ function requireBraceExpansion () { return []; options = options || {}; - var max = options.max == null ? Infinity : options.max; + var max = options.max == null ? EXPANSION_MAX : options.max; + var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength; + var maxDepth = options.maxDepth == null ? EXPANSION_MAX_DEPTH : options.maxDepth; + var maxRewrites = options.maxRewrites == null ? EXPANSION_MAX_REWRITES : options.maxRewrites; // I don't know why Bash 4.3 does this, but it does. // Anything starting with {} will have the first two bytes preserved @@ -27570,7 +27604,7 @@ function requireBraceExpansion () { str = '\\{\\}' + str.substr(2); } - return expand(escapeBraces(str), max, true).map(unescapeBraces); + return expand(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces); } function embrace(str) { @@ -27587,15 +27621,168 @@ function requireBraceExpansion () { return i >= y; } - function expand(str, max, isTop) { - var expansions = []; + // 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). + // + // `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 + // are appended to `outBase`, which the caller carries forward alongside them. + function combine( + acc, + base, + pre, + values, + max, + maxLength, + dropEmpties, + outBase + ) { + 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 + out.push(expansion); + outBase.push(base[a]); + length += expansion.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 + ) { + var n = body.split(/\.\./); + var N = []; + // A sequence body always splits into two or three parts, but the compiler + // can't know that. + /* c8 ignore start */ + if (n[0] === undefined || n[1] === undefined) { + return N + } + /* c8 ignore stop */ + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length); + var incr = + n.length === 3 && n[2] !== undefined ? + Math.max(Math.abs(numeric(n[2])), 1) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); + + var length = 0; + for (var i = x; test(i, y) && N.length < max; i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') { + c = ''; + } + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) { + c = '-' + z + c.slice(1); + } else { + c = z + c; + } + } + } + } + if (length + c.length > maxLength) break + N.push(c); + length += c.length; + } + return N + } + + function expand( + str, + max, + maxLength, + maxDepth, + depth, + maxRewrites, + isTop + ) { + // 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 + // depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no + // longer overflow the stack, and leaves a single accumulator whose size + // `maxLength` bounds directly (CVE-2026-14257). + var acc = ['']; + + // Bash drops empty results, but only when the *first* group of the run is a + // comma set - a sequence like `{a..\}` may legitimately yield ''. The drop + // is on the final strings, so it is applied to whichever `combine` produces + // them (the one with no brace set left in the tail). + // + // The old implementation recursed on `m.post`, so the drop tested only the + // expansion of the current call's substring. The `{a},b}` rewrite below turns + // `isTop` back on part-way through a string, starting a fresh such run, so + // the drop must ignore whatever `acc` already holds from earlier groups. + // `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; + var nextBase; - // The `{a},b}` rewrite below restarts expansion on a rewritten string with - // the same `max` and `isTop = true`. Loop instead of recursing so a long run - // of non-expanding `{}` groups can't exhaust the call stack. for (;;) { var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; + + // No brace set left: the rest of the string is literal. + if (!m) { + return combine(acc, accBase, str, [''], max, maxLength, dropEmpties, []) + } + + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + + // 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: + // the whole remainder is literal. The 2.x and 5.x lines instead keep + // expanding the tail, which is what bash does, but changing that here would + // 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, []) + } var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); @@ -27603,96 +27790,115 @@ function requireBraceExpansion () { var isOptions = m.body.indexOf(',') >= 0; if (!isSequence && !isOptions) { // {a},b} - if (m.post.match(/,(?!,).*\}/)) { + if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) { + rewrites++; str = m.pre + '{' + m.body + escClose + m.post; + // 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. isTop = true; + firstGroup = true; + dropEmpties = false; + accBase = []; + for (var b = 0; b < acc.length; b++) { + accBase.push(acc[b].length); + } continue } - return [str]; + // Nothing here expands, so the whole remaining string is literal. + return combine( + acc, + accBase, + pre + '{' + m.body + '}' + m.post, + [''], + max, + maxLength, + dropEmpties, + [] + ) + } + + if (firstGroup) { + dropEmpties = isTop && !isSequence; + firstGroup = false; } - var n; + var values; if (isSequence) { - n = m.body.split(/\.\./); + values = expandSequence(m.body, isAlphaSequence, max, maxLength); } else { - n = parseCommaParts(m.body); - if (n.length === 1) { + var n = parseCommaParts(m.body); + if (n.length === 1 && n[0] !== undefined) { // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], max, false).map(embrace); + n = expand(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace); + //XXX is this necessary? Can't seem to hit it in tests. + /* c8 ignore start */ if (n.length === 1) { - var post = m.post.length - ? expand(m.post, max, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); + nextBase = []; + acc = combine( + acc, + accBase, + pre + n[0], + [''], + max, + maxLength, + dropEmpties && !m.post.length, + nextBase + ); + accBase = nextBase; + if (!m.post.length) break + str = m.post; + continue } + /* c8 ignore stop */ } - } - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post, max, false) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length); - var incr = n.length == 3 - ? Math.max(Math.abs(numeric(n[2])), 1) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y) && N.length < max; i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } + // Values that `combine` is going to drop as empty produce no result, so + // they must not count against `max` - otherwise `{a,,b}` with `max: 2` + // would stop at `['a', '']` and yield one result instead of two. Skipping + // them outright keeps `values` bounded while leaving `max` a bound on + // *kept* results. A value is dropped when it adds nothing past the + // baseline, which is what `combine` tests. + var dropsEmpties = dropEmpties && !m.post.length && !pre; + for (var d = 0; dropsEmpties && d < acc.length; d++) { + if (acc[d].length !== accBase[d]) { + dropsEmpties = false; } - N.push(c); } - } else { - N = concatMap(n, function(el) { return expand(el, max, false) }); - } - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length && expansions.length < max; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); + values = []; + var valuesLength = 0; + outer: for (var j = 0; j < n.length; j++) { + var expanded = expand(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false); + for (var k = 0; k < expanded.length; k++) { + var v = expanded[k]; + if (dropsEmpties && !v) continue + if (values.length >= max || valuesLength + v.length > maxLength) { + break outer + } + values.push(v); + valuesLength += v.length; + } } } - return expansions; + nextBase = []; + acc = combine( + acc, + accBase, + pre, + values, + max, + maxLength, + dropEmpties && !m.post.length, + nextBase + ); + accBase = nextBase; + if (!m.post.length) break + str = m.post; } + + return acc } return braceExpansion; } @@ -31271,20 +31477,20 @@ function requireUuid () { return uuid_1; } -var constants$a = {}; +var constants$b = {}; -var hasRequiredConstants$a; +var hasRequiredConstants$b; -function requireConstants$a () { - if (hasRequiredConstants$a) return constants$a; - hasRequiredConstants$a = 1; - Object.defineProperty(constants$a, "__esModule", { value: true }); - constants$a.ManifestFilename = constants$a.TarFilename = constants$a.SystemTarPathOnWindows = constants$a.GnuTarPathOnWindows = constants$a.SocketTimeout = constants$a.DefaultRetryDelay = constants$a.DefaultRetryAttempts = constants$a.ArchiveToolType = constants$a.CompressionMethod = constants$a.CacheFilename = void 0; +function requireConstants$b () { + if (hasRequiredConstants$b) return constants$b; + hasRequiredConstants$b = 1; + Object.defineProperty(constants$b, "__esModule", { value: true }); + constants$b.ManifestFilename = constants$b.TarFilename = constants$b.SystemTarPathOnWindows = constants$b.GnuTarPathOnWindows = constants$b.SocketTimeout = constants$b.DefaultRetryDelay = constants$b.DefaultRetryAttempts = constants$b.ArchiveToolType = constants$b.CompressionMethod = constants$b.CacheFilename = void 0; var CacheFilename; (function (CacheFilename) { CacheFilename["Gzip"] = "cache.tgz"; CacheFilename["Zstd"] = "cache.tzst"; - })(CacheFilename || (constants$a.CacheFilename = CacheFilename = {})); + })(CacheFilename || (constants$b.CacheFilename = CacheFilename = {})); var CompressionMethod; (function (CompressionMethod) { CompressionMethod["Gzip"] = "gzip"; @@ -31292,28 +31498,28 @@ function requireConstants$a () { // This enum is for earlier version of zstd that does not have --long support CompressionMethod["ZstdWithoutLong"] = "zstd-without-long"; CompressionMethod["Zstd"] = "zstd"; - })(CompressionMethod || (constants$a.CompressionMethod = CompressionMethod = {})); + })(CompressionMethod || (constants$b.CompressionMethod = CompressionMethod = {})); var ArchiveToolType; (function (ArchiveToolType) { ArchiveToolType["GNU"] = "gnu"; ArchiveToolType["BSD"] = "bsd"; - })(ArchiveToolType || (constants$a.ArchiveToolType = ArchiveToolType = {})); + })(ArchiveToolType || (constants$b.ArchiveToolType = ArchiveToolType = {})); // The default number of retry attempts. - constants$a.DefaultRetryAttempts = 2; + constants$b.DefaultRetryAttempts = 2; // The default delay in milliseconds between retry attempts. - constants$a.DefaultRetryDelay = 5000; + constants$b.DefaultRetryDelay = 5000; // Socket timeout in milliseconds during download. If no traffic is received // over the socket during this period, the socket is destroyed and the download // is aborted. - constants$a.SocketTimeout = 5000; + constants$b.SocketTimeout = 5000; // The default path of GNUtar on hosted Windows runners - constants$a.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`; + constants$b.GnuTarPathOnWindows = `${process.env['PROGRAMFILES']}\\Git\\usr\\bin\\tar.exe`; // The default path of BSDtar on hosted Windows runners - constants$a.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`; - constants$a.TarFilename = 'cache.tar'; - constants$a.ManifestFilename = 'manifest.txt'; + constants$b.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32\\tar.exe`; + constants$b.TarFilename = 'cache.tar'; + constants$b.ManifestFilename = 'manifest.txt'; - return constants$a; + return constants$b; } var hasRequiredCacheUtils; @@ -31371,7 +31577,7 @@ function requireCacheUtils () { const semver = __importStar(requireSemver()); const util = __importStar(require$$0__default$1); const uuid_1 = requireUuid(); - const constants_1 = requireConstants$a(); + const constants_1 = requireConstants$b(); // From https://github.com/actions/toolkit/blob/main/packages/tool-cache/src/tool-cache.ts#L23 function createTempDirectory() { return __awaiter(this, void 0, void 0, function* () { @@ -32034,12 +32240,12 @@ function requireErrors$1 () { return errors$1; } -var constants$9; -var hasRequiredConstants$9; +var constants$a; +var hasRequiredConstants$a; -function requireConstants$9 () { - if (hasRequiredConstants$9) return constants$9; - hasRequiredConstants$9 = 1; +function requireConstants$a () { + if (hasRequiredConstants$a) return constants$a; + hasRequiredConstants$a = 1; /** @type {Record} */ const headerNameLowerCasedRecord = {}; @@ -32153,11 +32359,11 @@ function requireConstants$9 () { // Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`. Object.setPrototypeOf(headerNameLowerCasedRecord, null); - constants$9 = { + constants$a = { wellknownHeaderNames, headerNameLowerCasedRecord }; - return constants$9; + return constants$a; } var util$b; @@ -32176,7 +32382,7 @@ function requireUtil$b () { const { Blob } = require$$0__default; const nodeUtil = require$$0__default$1; const { stringify } = require$$1$1; - const { headerNameLowerCasedRecord } = requireConstants$9(); + const { headerNameLowerCasedRecord } = requireConstants$a(); const [nodeMajor, nodeMinor] = process.versions.node.split('.').map(v => Number(v)); @@ -32795,12 +33001,12 @@ function requireTimers () { return timers; } -var constants$8; -var hasRequiredConstants$8; +var constants$9; +var hasRequiredConstants$9; -function requireConstants$8 () { - if (hasRequiredConstants$8) return constants$8; - hasRequiredConstants$8 = 1; +function requireConstants$9 () { + if (hasRequiredConstants$9) return constants$9; + hasRequiredConstants$9 = 1; const { MessageChannel, receiveMessageOnPort } = require$$0$9; @@ -32926,7 +33132,7 @@ function requireConstants$8 () { return receiveMessageOnPort(channel.port2).message }; - constants$8 = { + constants$9 = { DOMException, structuredClone, subresource, @@ -32951,7 +33157,7 @@ function requireConstants$8 () { forbiddenMethodsSet, referrerPolicySet }; - return constants$8; + return constants$9; } var global$2; @@ -33009,7 +33215,7 @@ function requireUtil$a () { if (hasRequiredUtil$a) return util$a; hasRequiredUtil$a = 1; - const { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } = requireConstants$8(); + const { redirectStatusSet, referrerPolicySet: referrerPolicyTokens, badPortsSet } = requireConstants$9(); const { getGlobalOrigin } = requireGlobal$1(); const { performance } = require$$2$2; const { isBlobLike, toUSVString, ReadableStreamFrom } = requireUtil$b(); @@ -35461,12 +35667,12 @@ function requireDataURL () { return dataURL; } -var file$2; -var hasRequiredFile$2; +var file$3; +var hasRequiredFile$3; -function requireFile$2 () { - if (hasRequiredFile$2) return file$2; - hasRequiredFile$2 = 1; +function requireFile$3 () { + if (hasRequiredFile$3) return file$3; + hasRequiredFile$3 = 1; const { Blob, File: NativeFile } = require$$0__default; const { types } = require$$0__default$1; @@ -35809,8 +36015,8 @@ function requireFile$2 () { ) } - file$2 = { File, FileLike, isFileLike }; - return file$2; + file$3 = { File, FileLike, isFileLike }; + return file$3; } var formdata; @@ -35822,7 +36028,7 @@ function requireFormdata () { const { isBlobLike, toUSVString, makeIterator } = requireUtil$a(); const { kState } = requireSymbols$3(); - const { File: UndiciFile, FileLike, isFileLike } = requireFile$2(); + const { File: UndiciFile, FileLike, isFileLike } = requireFile$3(); const { webidl } = requireWebidl(); const { Blob, File: NativeFile } = require$$0__default; @@ -36106,13 +36312,13 @@ function requireBody () { const { FormData } = requireFormdata(); const { kState } = requireSymbols$3(); const { webidl } = requireWebidl(); - const { DOMException, structuredClone } = requireConstants$8(); + const { DOMException, structuredClone } = requireConstants$9(); const { Blob, File: NativeFile } = require$$0__default; const { kBodyUsed } = requireSymbols$4(); const assert$1 = assert; const { isErrored } = requireUtil$b(); const { isUint8Array, isArrayBuffer } = require$$5; - const { File: UndiciFile } = requireFile$2(); + const { File: UndiciFile } = requireFile$3(); const { parseMIMEType, serializeAMimeType } = requireDataURL(); let random; @@ -37638,7 +37844,7 @@ function requireConnect () { return connect; } -var constants$7 = {}; +var constants$8 = {}; var utils$3 = {}; @@ -37664,11 +37870,11 @@ function requireUtils$5 () { return utils$3; } -var hasRequiredConstants$7; +var hasRequiredConstants$8; -function requireConstants$7 () { - if (hasRequiredConstants$7) return constants$7; - hasRequiredConstants$7 = 1; +function requireConstants$8 () { + if (hasRequiredConstants$8) return constants$8; + hasRequiredConstants$8 = 1; (function (exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.SPECIAL_HEADERS = exports.HEADER_STATE = exports.MINOR = exports.MAJOR = exports.CONNECTION_TOKEN_CHARS = exports.HEADER_CHARS = exports.TOKEN = exports.STRICT_TOKEN = exports.HEX = exports.URL_CHAR = exports.STRICT_URL_CHAR = exports.USERINFO_CHARS = exports.MARK = exports.ALPHANUM = exports.NUM = exports.HEX_MAP = exports.NUM_MAP = exports.ALPHA = exports.FINISH = exports.H_METHOD_MAP = exports.METHOD_MAP = exports.METHODS_RTSP = exports.METHODS_ICE = exports.METHODS_HTTP = exports.METHODS = exports.LENIENT_FLAGS = exports.FLAGS = exports.TYPE = exports.ERROR = void 0; @@ -37941,8 +38147,8 @@ function requireConstants$7 () { 'upgrade': HEADER_STATE.UPGRADE, }; - } (constants$7)); - return constants$7; + } (constants$8)); + return constants$8; } var RedirectHandler_1; @@ -38692,7 +38898,7 @@ function requireClient () { resume(client); } - const constants = requireConstants$7(); + const constants = requireConstants$8(); const createRedirectInterceptor = requireRedirectInterceptor(); const EMPTY_BUF = Buffer.alloc(0); @@ -45018,7 +45224,7 @@ function requireResponse$1 () { redirectStatusSet, nullBodyStatus, DOMException - } = requireConstants$8(); + } = requireConstants$9(); const { kState, kHeaders, kGuard, kRealm } = requireSymbols$3(); const { webidl } = requireWebidl(); const { FormData } = requireFormdata(); @@ -45602,7 +45808,7 @@ function requireRequest () { requestCredentials, requestCache, requestDuplex - } = requireConstants$8(); + } = requireConstants$9(); const { kEnumerableProperty } = util; const { kHeaders, kSignal, kState, kGuard, kRealm } = requireSymbols$3(); const { webidl } = requireWebidl(); @@ -46584,7 +46790,7 @@ function requireFetch () { requestBodyHeader, subresourceSet, DOMException - } = requireConstants$8(); + } = requireConstants$9(); const { kHeadersList } = requireSymbols$4(); const EE = require$$0__default$3; const { Readable, pipeline } = require$$0__default$2; @@ -49025,7 +49231,7 @@ function requireUtil$8 () { } = requireSymbols$2(); const { ProgressEvent } = requireProgressevent(); const { getEncoding } = requireEncoding(); - const { DOMException } = requireConstants$8(); + const { DOMException } = requireConstants$9(); const { serializeAMimeType, parseMIMEType } = requireDataURL(); const { types } = require$$0__default$1; const { StringDecoder } = require$$6; @@ -50829,12 +51035,12 @@ function requireCachestorage () { return cachestorage; } -var constants$6; -var hasRequiredConstants$6; +var constants$7; +var hasRequiredConstants$7; -function requireConstants$6 () { - if (hasRequiredConstants$6) return constants$6; - hasRequiredConstants$6 = 1; +function requireConstants$7 () { + if (hasRequiredConstants$7) return constants$7; + hasRequiredConstants$7 = 1; // https://wicg.github.io/cookie-store/#cookie-maximum-attribute-value-size const maxAttributeValueSize = 1024; @@ -50842,11 +51048,11 @@ function requireConstants$6 () { // https://wicg.github.io/cookie-store/#cookie-maximum-name-value-pair-size const maxNameValuePairSize = 4096; - constants$6 = { + constants$7 = { maxAttributeValueSize, maxNameValuePairSize }; - return constants$6; + return constants$7; } var util$6; @@ -51138,7 +51344,7 @@ function requireParse$1 () { if (hasRequiredParse$1) return parse$4; hasRequiredParse$1 = 1; - const { maxNameValuePairSize, maxAttributeValueSize } = requireConstants$6(); + const { maxNameValuePairSize, maxAttributeValueSize } = requireConstants$7(); const { isCTLExcludingHtab } = requireUtil$6(); const { collectASequenceOfCodePointsFast } = requireDataURL(); const assert$1 = assert; @@ -51647,12 +51853,12 @@ function requireCookies () { return cookies; } -var constants$5; -var hasRequiredConstants$5; +var constants$6; +var hasRequiredConstants$6; -function requireConstants$5 () { - if (hasRequiredConstants$5) return constants$5; - hasRequiredConstants$5 = 1; +function requireConstants$6 () { + if (hasRequiredConstants$6) return constants$6; + hasRequiredConstants$6 = 1; // This is a Globally Unique Identifier unique used // to validate that the endpoint accepts websocket @@ -51694,7 +51900,7 @@ function requireConstants$5 () { const emptyBuffer = Buffer.allocUnsafe(0); - constants$5 = { + constants$6 = { uid, staticPropertyDescriptors, states, @@ -51703,7 +51909,7 @@ function requireConstants$5 () { parserStates, emptyBuffer }; - return constants$5; + return constants$6; } var symbols; @@ -52045,7 +52251,7 @@ function requireUtil$5 () { hasRequiredUtil$5 = 1; const { kReadyState, kController, kResponse, kBinaryType, kWebSocketURL } = requireSymbols(); - const { states, opcodes } = requireConstants$5(); + const { states, opcodes } = requireConstants$6(); const { MessageEvent, ErrorEvent } = requireEvents(); /* globals Blob */ @@ -52253,7 +52459,7 @@ function requireConnection () { hasRequiredConnection = 1; const diagnosticsChannel = require$$0$a; - const { uid, states } = requireConstants$5(); + const { uid, states } = requireConstants$6(); const { kReadyState, kSentClose, @@ -52551,7 +52757,7 @@ function requireFrame () { if (hasRequiredFrame) return frame; hasRequiredFrame = 1; - const { maxUnsigned16Bit } = requireConstants$5(); + const { maxUnsigned16Bit } = requireConstants$6(); /** @type {import('crypto')} */ let crypto; @@ -52634,7 +52840,7 @@ function requireReceiver () { const { Writable } = require$$0__default$2; const diagnosticsChannel = require$$0$a; - const { parserStates, opcodes, states, emptyBuffer } = requireConstants$5(); + const { parserStates, opcodes, states, emptyBuffer } = requireConstants$6(); const { kReadyState, kSentClose, kResponse, kReceivedClose } = requireSymbols(); const { isValidStatusCode, failWebsocketConnection, websocketMessageReceived } = requireUtil$5(); const { WebsocketFrameSend } = requireFrame(); @@ -52985,10 +53191,10 @@ function requireWebsocket () { hasRequiredWebsocket = 1; const { webidl } = requireWebidl(); - const { DOMException } = requireConstants$8(); + const { DOMException } = requireConstants$9(); const { URLSerializer } = requireDataURL(); const { getGlobalOrigin } = requireGlobal$1(); - const { staticPropertyDescriptors, states, opcodes, emptyBuffer } = requireConstants$5(); + const { staticPropertyDescriptors, states, opcodes, emptyBuffer } = requireConstants$6(); const { kWebSocketURL, kReadyState, @@ -53748,7 +53954,7 @@ function requireUndici () { undici.Response = requireResponse$1().Response; undici.Request = requireRequest().Request; undici.FormData = requireFormdata().FormData; - undici.File = requireFile$2().File; + undici.File = requireFile$3().File; undici.FileReader = requireFilereader().FileReader; const { setGlobalOrigin, getGlobalOrigin } = requireGlobal$1(); @@ -54737,13 +54943,13 @@ var beforeAfterHookExports = requireBeforeAfterHook(); const VERSION$5 = "9.0.6"; -const userAgent$2 = `octokit-endpoint.js/${VERSION$5} ${getUserAgent()}`; +const userAgent$3 = `octokit-endpoint.js/${VERSION$5} ${getUserAgent()}`; const DEFAULTS = { method: "GET", baseUrl: "https://api.github.com", headers: { accept: "application/vnd.github.v3+json", - "user-agent": userAgent$2 + "user-agent": userAgent$3 }, mediaType: { format: "" @@ -58390,7 +58596,7 @@ function requireRequestUtils () { requestUtils.retryHttpClientResponse = requestUtils.retryTypedResponse = requestUtils.retry = requestUtils.isRetryableStatusCode = requestUtils.isServerErrorStatusCode = requestUtils.isSuccessStatusCode = void 0; const core = __importStar(requireCore()); const http_client_1 = requireLib$3(); - const constants_1 = requireConstants$a(); + const constants_1 = requireConstants$b(); function isSuccessStatusCode(statusCode) { if (!statusCode) { return false; @@ -154897,7 +155103,7 @@ function requireSrc$7 () { return src$6; } -var commonjs$f = {}; +var commonjs$g = {}; var namedReferences = {}; @@ -155030,12 +155236,12 @@ function requireSurrogatePairs () { return surrogatePairs; } -var hasRequiredCommonjs$f; +var hasRequiredCommonjs$g; -function requireCommonjs$f () { - if (hasRequiredCommonjs$f) return commonjs$f; - hasRequiredCommonjs$f = 1; - var __assign = (commonjs$f && commonjs$f.__assign) || function () { +function requireCommonjs$g () { + if (hasRequiredCommonjs$g) return commonjs$g; + hasRequiredCommonjs$g = 1; + var __assign = (commonjs$g && commonjs$g.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; @@ -155046,10 +155252,10 @@ function requireCommonjs$f () { }; return __assign.apply(this, arguments); }; - Object.defineProperty(commonjs$f, "__esModule", { value: true }); - commonjs$f.encode = encode; - commonjs$f.decodeEntity = decodeEntity; - commonjs$f.decode = decode; + Object.defineProperty(commonjs$g, "__esModule", { value: true }); + commonjs$g.encode = encode; + commonjs$g.decodeEntity = decodeEntity; + commonjs$g.decode = decode; var named_references_js_1 = requireNamedReferences(); var numeric_unicode_map_js_1 = requireNumericUnicodeMap(); var surrogate_pairs_js_1 = requireSurrogatePairs(); @@ -155163,7 +155369,7 @@ function requireCommonjs$f () { return text.replace(decodeRegExp, function (entity) { return getDecodedEntity(entity, references, isAttribute, isStrict); }); } - return commonjs$f; + return commonjs$g; } var retryRequest = {exports: {}}; @@ -157433,11 +157639,11 @@ var packageJsonHelper = {}; var name = "@google-cloud/storage"; var description = "Cloud Storage Client Library for Node.js"; -var version = "7.21.0"; +var version = "7.22.0"; var license = "Apache-2.0"; var author = "Google Inc."; var engines = { - node: ">=14" + node: ">=18" }; var repository = { type: "git", @@ -157501,9 +157707,9 @@ var scripts = { "presystem-test": "npm run compile -- --sourceMap", pretest: "npm run compile -- --sourceMap", "samples-test": "npm link && cd samples/ && npm link ../ && npm test && cd ../", - "system-test:esm": "mocha build/esm/system-test --timeout 600000 --exit", - "system-test": "mocha build/cjs/system-test --timeout 600000 --exit", - test: "cross-env NODE_OPTIONS='--no-deprecation' c8 mocha build/cjs/test" + "system-test:esm": "mkdir -p $HOME/.config && mocha build/esm/system-test --timeout 600000 --exit", + "system-test": "mkdir -p $HOME/.config && mocha build/cjs/system-test --timeout 600000 --exit", + test: "cross-env NODE_OPTIONS=\"--require ./scripts/preload-yargs.cjs --no-deprecation\" c8 mocha build/cjs/test" }; var dependencies = { "@google-cloud/paginator": "^5.0.0", @@ -157538,7 +157744,7 @@ var devDependencies = { "@types/request": "^2.48.4", "@types/sinon": "^17.0.0", "@types/tmp": "0.2.6", - "@types/yargs": "^17.0.10", + "@types/yargs": "^17.0.35", c8: "^9.0.0", "form-data": "^4.0.4", "gapic-tools": "^0.4.0", @@ -157557,7 +157763,7 @@ var devDependencies = { "path-to-regexp": "6.3.0", tmp: "^0.2.0", typescript: "^5.1.6", - yargs: "^17.3.1", + yargs: "^17.7.2", "cross-env": "^7.0.3" }; var homepage = "https://github.com/googleapis/google-cloud-node/tree/main/handwritten/storage"; @@ -160981,11 +161187,11 @@ function require_stream_passthrough () { } var pipeline_1; -var hasRequiredPipeline$4; +var hasRequiredPipeline$5; -function requirePipeline$4 () { - if (hasRequiredPipeline$4) return pipeline_1; - hasRequiredPipeline$4 = 1; +function requirePipeline$5 () { + if (hasRequiredPipeline$5) return pipeline_1; + hasRequiredPipeline$5 = 1; var eos; function once(callback) { @@ -161091,7 +161297,7 @@ function requireReadable () { exports.Transform = require_stream_transform(); exports.PassThrough = require_stream_passthrough(); exports.finished = requireEndOfStream$1(); - exports.pipeline = requirePipeline$4(); + exports.pipeline = requirePipeline$5(); } } (readable, readable.exports)); return readable.exports; @@ -161542,7 +161748,7 @@ function requireUtil$1 () { * @module common/util */ const projectify_1 = requireSrc$7(); - const htmlEntities = __importStar(/*@__PURE__*/ requireCommonjs$f()); + const htmlEntities = __importStar(/*@__PURE__*/ requireCommonjs$g()); const google_auth_library_1 = requireSrc$8(); const retry_request_1 = __importDefault(requireRetryRequest()); const stream_1 = require$$0__default$2; @@ -162125,6 +162331,20 @@ function requireUtil$1 () { delete reqOpts.json.autoPaginate; delete reqOpts.json.autoPaginateVal; reqOpts.json = (0, projectify_1.replaceProjectIdToken)(reqOpts.json, projectId); + const headers = reqOpts.headers || {}; + if (typeof headers.set === 'function' && + typeof headers.has === 'function') { + if (!headers.has('content-type')) { + headers.set('Content-Type', 'application/json'); + } + reqOpts.headers = headers; + } + else { + const hasContentType = Object.keys(headers).some(key => key.toLowerCase() === 'content-type'); + reqOpts.headers = hasContentType + ? headers + : { ...headers, 'Content-Type': 'application/json' }; + } } reqOpts.uri = (0, projectify_1.replaceProjectIdToken)(reqOpts.uri, projectId); return reqOpts; @@ -164636,7 +164856,7 @@ function requireAcl () { return acl; } -var file$1 = {}; +var file$2 = {}; var resumableUpload = {}; @@ -165929,7 +166149,7 @@ function requireHashStreamValidator () { const crypto_1 = crypto__default; const stream_1 = require$$0__default$2; const crc32c_js_1 = requireCrc32c(); - const file_js_1 = requireFile$1(); + const file_js_1 = requireFile$2(); class HashStreamValidator extends stream_1.Transform { constructor(options = {}) { super(); @@ -166109,7 +166329,7 @@ function requireResumableUpload () { const crypto = __importStar(crypto__default); const util_js_1 = requireUtil$2(); const util_js_2 = requireUtil$1(); - const file_js_1 = requireFile$1(); + const file_js_1 = requireFile$2(); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const package_json_helper_cjs_1 = requirePackageJsonHelper(); @@ -166912,7 +167132,7 @@ function requireResumableUpload () { else { const retryDelay = this.getRetryDelay(); if (retryDelay <= 0) { - this.destroy(new Error(`Retry total time limit exceeded - ${JSON.stringify(resp.data)}`)); + this.destroy(buildRetryError('Retry total time limit exceeded', resp)); return; } // Unshift the local cache back in case it's needed for the next request. @@ -166930,7 +167150,7 @@ function requireResumableUpload () { this.numRetries++; } else { - this.destroy(new Error(`Retry limit exceeded - ${JSON.stringify(resp.data)}`)); + this.destroy(buildRetryError('Retry limit exceeded', resp)); } } /** @@ -167008,6 +167228,62 @@ function requireResumableUpload () { headers['X-Goog-Hash'] = checksums.join(','); } }; + function buildRetryError(prefix, resp) { + var _a, _b, _c, _d; + const parts = []; + if (typeof resp.status === 'number' && !isNaN(resp.status)) { + parts.push(`status: ${resp.status}`); + } + const err = resp.data; + if (err !== undefined && err !== null) { + if (typeof err === 'object') { + const gaxiosErrLike = err; + const errParts = []; + if (gaxiosErrLike.message) { + errParts.push(String(gaxiosErrLike.message)); + } + const status = (_a = gaxiosErrLike.status) !== null && _a !== void 0 ? _a : (_b = gaxiosErrLike.response) === null || _b === void 0 ? void 0 : _b.status; + if (typeof status === 'number' && !isNaN(status) && status !== resp.status) { + errParts.push(`status: ${status}`); + } + const statusText = (_c = gaxiosErrLike.response) === null || _c === void 0 ? void 0 : _c.statusText; + if (statusText) { + errParts.push(`statusText: ${statusText}`); + } + const responseData = (_d = gaxiosErrLike.response) === null || _d === void 0 ? void 0 : _d.data; + if (responseData !== undefined && responseData !== null && responseData !== '') { + errParts.push(`response: ${typeof responseData === 'object' + ? JSON.stringify(responseData) + : responseData}`); + } + if (gaxiosErrLike.code) { + errParts.push(`code: ${String(gaxiosErrLike.code)}`); + } + if (errParts.length > 0) { + parts.push(...errParts); + } + else if (err instanceof Error) { + parts.push(err.toString() || err.name || 'Unknown Error'); + } + else { + const stringified = JSON.stringify(err); + if (stringified && stringified !== '{}') { + parts.push(stringified); + } + } + } + else if (typeof err === 'string') { + if (err !== '') { + parts.push(err); + } + } + else { + parts.push(String(err)); + } + } + const suffix = parts.join(' - '); + return new Error(`${prefix} - ${suffix || 'Unknown Error'}`); + } function upload(cfg) { return new Upload(cfg); } @@ -167378,11 +167654,11 @@ function requireSigner () { return signer; } -var hasRequiredFile$1; +var hasRequiredFile$2; -function requireFile$1 () { - if (hasRequiredFile$1) return file$1; - hasRequiredFile$1 = 1; +function requireFile$2 () { + if (hasRequiredFile$2) return file$2; + hasRequiredFile$2 = 1; // Copyright 2019 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -167396,7 +167672,7 @@ function requireFile$1 () { // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - var __createBinding = (file$1 && file$1.__createBinding) || (Object.create ? (function(o, m, k, k2) { + var __createBinding = (file$2 && file$2.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { @@ -167407,12 +167683,12 @@ function requireFile$1 () { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); - var __setModuleDefault = (file$1 && file$1.__setModuleDefault) || (Object.create ? (function(o, v) { + var __setModuleDefault = (file$2 && file$2.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); - var __importStar = (file$1 && file$1.__importStar) || (function () { + var __importStar = (file$2 && file$2.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; @@ -167429,17 +167705,17 @@ function requireFile$1 () { return result; }; })(); - var __classPrivateFieldGet = (file$1 && file$1.__classPrivateFieldGet) || function (receiver, state, kind, f) { + var __classPrivateFieldGet = (file$2 && file$2.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; - var __importDefault = (file$1 && file$1.__importDefault) || function (mod) { + var __importDefault = (file$2 && file$2.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _File_instances, _File_validateIntegrity; - Object.defineProperty(file$1, "__esModule", { value: true }); - file$1.File = file$1.FileExceptionMessages = file$1.RequestError = file$1.SkipReason = file$1.STORAGE_POST_POLICY_BASE_URL = file$1.ActionToHTTPMethod = void 0; + Object.defineProperty(file$2, "__esModule", { value: true }); + file$2.File = file$2.FileExceptionMessages = file$2.RequestError = file$2.SkipReason = file$2.STORAGE_POST_POLICY_BASE_URL = file$2.ActionToHTTPMethod = void 0; const index_js_1 = requireNodejsCommon(); const promisify_1 = requireSrc$4(); const crypto = __importStar(crypto__default); @@ -167464,11 +167740,11 @@ function requireFile$1 () { ActionToHTTPMethod["write"] = "PUT"; ActionToHTTPMethod["delete"] = "DELETE"; ActionToHTTPMethod["resumable"] = "POST"; - })(ActionToHTTPMethod || (file$1.ActionToHTTPMethod = ActionToHTTPMethod = {})); + })(ActionToHTTPMethod || (file$2.ActionToHTTPMethod = ActionToHTTPMethod = {})); /** * @deprecated - no longer used */ - file$1.STORAGE_POST_POLICY_BASE_URL = 'https://storage.googleapis.com'; + file$2.STORAGE_POST_POLICY_BASE_URL = 'https://storage.googleapis.com'; /** * @private */ @@ -167496,10 +167772,10 @@ function requireFile$1 () { SkipReason["ILLEGAL_CHARACTER"] = "ILLEGAL_CHARACTER"; SkipReason["ALREADY_EXISTS"] = "ALREADY_EXISTS"; SkipReason["DOWNLOAD_ERROR"] = "DOWNLOAD_ERROR"; - })(SkipReason || (file$1.SkipReason = SkipReason = {})); + })(SkipReason || (file$2.SkipReason = SkipReason = {})); class RequestError extends Error { } - file$1.RequestError = RequestError; + file$2.RequestError = RequestError; const SEVEN_DAYS = 7 * 24 * 60 * 60; const GS_UTIL_URL_REGEX = /(gs):\/\/([a-z0-9_.-]+)\/(.+)/g; const HTTPS_PUBLIC_URL_REGEX = /(https):\/\/(storage\.googleapis\.com)\/([a-z0-9_.-]+)\/(.+)/g; @@ -167517,7 +167793,7 @@ function requireFile$1 () { FileExceptionMessages["UPLOAD_MISMATCH"] = "The uploaded data did not match the data from the server.\n As a precaution, the file has been deleted.\n To be sure the content is the same, you should try uploading the file again."; FileExceptionMessages["MD5_RESUMED_UPLOAD"] = "MD5 cannot be used with a continued resumable upload as MD5 cannot be extended from an existing value"; FileExceptionMessages["MISSING_RESUME_CRC32C_FINAL_UPLOAD"] = "The CRC32C is missing for the final portion of a resumed upload, which is required for validation. Please provide `resumeCRC32C` if validation is required, or disable `validation`."; - })(FileExceptionMessages || (file$1.FileExceptionMessages = FileExceptionMessages = {})); + })(FileExceptionMessages || (file$2.FileExceptionMessages = FileExceptionMessages = {})); /** * A File object is created from your {@link Bucket} object using * {@link Bucket#file}. @@ -168941,6 +169217,27 @@ function requireFile$1 () { } // remove temporary noop listener as we now create a pipeline that handles the errors emitStream.removeListener('error', noop); + if (fileWriteStream.destroyed) { + let callbackCalled = false; + const onError = (err) => { + if (!callbackCalled) { + callbackCalled = true; + pipelineCallback(err); + } + }; + fileWriteStream.once('error', onError); + emitStream.destroy(); + process.nextTick(() => { + fileWriteStream.removeListener('error', onError); + if (!callbackCalled) { + callbackCalled = true; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const err = fileWriteStream.errored || new Error('Write stream destroyed'); + pipelineCallback(err); + } + }); + return; + } (0, stream_1.pipeline)(emitStream, ...transformStreams, fileWriteStream, async (e) => { if (e) { return pipelineCallback(e); @@ -169808,6 +170105,7 @@ function requireFile$1 () { contentMd5: cfg.contentMd5, contentType: cfg.contentType, host: cfg.host, + signingEndpoint: cfg.signingEndpoint, }; if (cfg.cname) { signConfig.cname = cfg.cname; @@ -170942,7 +171240,7 @@ function requireFile$1 () { return Buffer.concat(buf); } } - file$1.File = File; + file$2.File = File; _File_instances = new WeakSet(), _File_validateIntegrity = /** * @@ -171005,7 +171303,7 @@ function requireFile$1 () { 'restore', ], }); - return file$1; + return file$2; } var iam = {}; @@ -171652,7 +171950,7 @@ function requireBucket () { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(bucket, "__esModule", { value: true }); - bucket.Bucket = bucket.BucketExceptionMessages = bucket.AvailableServiceObjectMethods = bucket.BucketActionToHTTPMethod = void 0; + bucket.Bucket = bucket.BucketExceptionMessages = bucket.AvailableServiceObjectMethods = bucket.BucketActionToHTTPMethod = bucket.ComposeCleanupError = void 0; const index_js_1 = requireNodejsCommon(); const paginator_1 = requireSrc$3(); const promisify_1 = requireSrc$4(); @@ -171664,13 +171962,23 @@ function requireBucket () { const async_retry_1 = __importDefault(requireLib()); const util_js_1 = requireUtil$2(); const acl_js_1 = requireAcl(); - const file_js_1 = requireFile$1(); + const file_js_1 = requireFile$2(); const iam_js_1 = requireIam(); const notification_js_1 = requireNotification(); const storage_js_1 = requireStorage(); const signer_js_1 = requireSigner(); const stream_1 = require$$0__default$2; const url_1 = require$$2$3; + class ComposeCleanupError extends Error { + constructor(message, errors, newFile, apiResponse) { + super(message); + this.name = 'ComposeCleanupError'; + this.errors = errors; + this.newFile = newFile; + this.apiResponse = apiResponse; + } + } + bucket.ComposeCleanupError = ComposeCleanupError; var BucketActionToHTTPMethod; (function (BucketActionToHTTPMethod) { BucketActionToHTTPMethod["list"] = "GET"; @@ -172633,7 +172941,9 @@ function requireBucket () { * metadata's `kms_key_name` value, if any. * @property {string} [userProject] The ID of the project which will be * billed for the request. - */ + * @property {boolean} [deleteSourceObjects] If true, the source objects + * will be permanently deleted after a successful compose operation. + */ /** * @callback CombineCallback * @param {?Error} err Request error, if any. @@ -172666,7 +172976,8 @@ function requireBucket () { * metadata's `kms_key_name` value, if any. * @param {string} [options.userProject] The ID of the project which will be * billed for the request. - + * @param {boolean} [options.deleteSourceObjects] If true, the source objects + * will be permanently deleted after a successful compose operation. * @param {CombineCallback} [callback] Callback function. * @returns {Promise} * @@ -172743,8 +173054,11 @@ function requireBucket () { storage_js_1.IdempotencyStrategy.RetryNever) { maxRetries = 0; } - if (options.ifGenerationMatch === undefined) { - Object.assign(options, destinationFile.instancePreconditionOpts, options); + const deleteSourceObjects = options.deleteSourceObjects; + const requestQueryObject = Object.assign({}, options); + delete requestQueryObject.deleteSourceObjects; + if (requestQueryObject.ifGenerationMatch === undefined) { + Object.assign(requestQueryObject, destinationFile.instancePreconditionOpts, requestQueryObject); } // Make the request from the destination File object. destinationFile.request({ @@ -172755,26 +173069,55 @@ function requireBucket () { destination: { contentType: destinationFile.metadata.contentType, contentEncoding: destinationFile.metadata.contentEncoding, - contexts: options.contexts || destinationFile.metadata.contexts, + contexts: requestQueryObject.contexts || destinationFile.metadata.contexts, }, sourceObjects: sources.map(source => { + var _a, _b; const sourceObject = { name: source.name, }; - if (source.metadata && source.metadata.generation) { - sourceObject.generation = parseInt(source.metadata.generation.toString()); + const generation = (_a = source.generation) !== null && _a !== void 0 ? _a : (_b = source.metadata) === null || _b === void 0 ? void 0 : _b.generation; + if (generation !== undefined) { + sourceObject.generation = parseInt(generation.toString()); } return sourceObject; }), }, - qs: options, + qs: requestQueryObject, }, (err, resp) => { this.storage.retryOptions.autoRetry = this.instanceRetryValue; if (err) { callback(err, null, resp); return; } - callback(null, destinationFile, resp); + if (deleteSourceObjects) { + const deletePromises = sources.map(source => { + var _a, _b; + const deleteOptions = { + ignoreNotFound: true, + userProject: options.userProject, + }; + const generation = (_a = source.generation) !== null && _a !== void 0 ? _a : (_b = source.metadata) === null || _b === void 0 ? void 0 : _b.generation; + if (generation !== undefined) { + deleteOptions.ifGenerationMatch = generation; + } + return source + .delete(deleteOptions) + .catch(deleteErr => deleteErr); + }); + Promise.all(deletePromises).then(results => { + const errors = results.filter((res) => res instanceof Error); + if (errors.length > 0) { + const cleanupErr = new ComposeCleanupError(`Compose operation succeeded, but cleaning up source objects failed. Failed to delete ${errors.length} source object(s).`, errors, destinationFile, resp); + callback(cleanupErr, destinationFile, resp); + return; + } + callback(null, destinationFile, resp); + }); + } + else { + callback(null, destinationFile, resp); + } }); } /** @@ -175036,10 +175379,16 @@ function requireBucket () { if (options.onUploadProgress) { writable.on('progress', options.onUploadProgress); } - fs.createReadStream(pathString) - .on('error', bail) + const readStream = fs.createReadStream(pathString); + readStream + .on('error', err => { + readStream.destroy(); + writable.destroy(); + bail(err); + }) .pipe(writable) .on('error', err => { + readStream.destroy(); if (this.storage.retryOptions.autoRetry && this.storage.retryOptions.retryableErrorFn(err)) { return reject(err); @@ -175715,7 +176064,7 @@ function requireStorage () { const stream_1 = require$$0__default$2; const bucket_js_1 = requireBucket(); const channel_js_1 = requireChannel(); - const file_js_1 = requireFile$1(); + const file_js_1 = requireFile$2(); const util_js_1 = requireUtil$2(); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore @@ -176881,7 +177230,7 @@ var hasRequiredFxp; function requireFxp () { if (hasRequiredFxp) return fxp.exports; hasRequiredFxp = 1; - (()=>{var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:true,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:true});}},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(false===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(true!==r)return y(r.err.code,r.err.msg,w(t,i+r.err.line));n=true;}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=true);}}else {const a=x(u,e);if(true!==a)return y(a.err.code,a.err.msg,w(t,s-u.length+a.err.line));if(true===r)return y("InvalidXml","Multiple possible root nodes found.",w(t,s));-1!==e.unpairedTags.indexOf(l)||i.push({tagName:l,tagStartPos:o}),n=true;}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=false;for(;e"===t[e]&&""===n){r=true;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: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,unicode:false},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:false,isArray:()=>false,commentPropName:false,unpairedTags:[],processEntities:true,htmlEntities:false,entityDecoder:null,ignoreDeclaration:false,ignorePiTags:false,transformTagName:false,transformAttributeName:false,updateTag:function(t,e,i){return t},captureMetaData:false,maxNestedTags:100,strictReservedNames:true,jPath:true,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:false!==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"}:_(true)}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=false}={})=>((t="1.0",e=false)=>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=false,o=false,a="";for(;e"===t[e]){if(o?"-"===t[e-1]&&"-"===t[e-2]&&(o=false,r--):r--,0===r)break}else "["===t[e]?s=true: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(false!==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=true;}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 false;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=true){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 false;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 true;return false}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=true){const i=t||this.separator;if(i===this.separator&&true===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 false;for(let e=0;e=0&&e>=0;){const n=t[i];if("deep-wildcard"===n.type){if(i--,i<0)return true;const n=t[i];let r=false;for(let t=e;t>=0;t--)if(this._matchSegment(n,this.path[t],t===this.path.length-1)){e=t-1,i--,r=true;break}if(!r)return false}else {if(!this._matchSegment(n,this.path[e],e===this.path.length-1))return false;e--,i--;}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag)return false;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return false;if(void 0!==t.attrName){if(!i)return false;if(!e.values||!(t.attrName in e.values))return false;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return false}if(void 0!==t.position){if(!i)return false;const n=e.counter??0;if("first"===t.position&&0!==n)return false;if("odd"===t.position&&n%2!=1)return false;if("even"===t.position&&n%2!=0)return false;if("nth"===t.position&&n!==t.positionValue)return false}return true}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??true,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 true;const r=t(e,i);if(r===ct.BLOCK)return false;if(r===ct.THROW)throw new Error(`[EntityDecoder] Registration of ${n} entity "&${e};" was rejected by hook`);return true}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