diff --git a/.github/actions/post-comment/action.yml b/.github/actions/post-comment/action.yml new file mode 100644 index 0000000000..28d202a81d --- /dev/null +++ b/.github/actions/post-comment/action.yml @@ -0,0 +1,41 @@ +name: "Post comment" +description: "Create or update a sticky PR comment identified by a caller-provided marker." +inputs: + marker: + description: > + Non-empty plain-text identifier for the comment. Use a unique, stable value + for each distinct comment; it is automatically wrapped in a hidden HTML comment. + required: true + body: + description: "Full comment markdown." + required: true + update-only: + description: Do nothing if no comment with the specified marker exists. + required: false + default: "false" + issue-id: + description: > + The issue or pull request number to post/update the comment on. + Defaults to the current pull request if not provided. + required: false + token: + description: "The GitHub token to authenticate with." + required: true +runs: + using: composite + steps: + - name: Post comment + shell: bash + env: + BODY: ${{ inputs.body }} + MARKER: ${{ inputs.marker }} + UPDATE_ONLY: ${{ case(inputs.update-only == 'true', '--update-only', '') }} + GH_TOKEN: ${{ inputs.token }} + ISSUE_ID: ${{ inputs.issue-id || github.event.pull_request.number }} + run: | + npx tsx ./pr-checks/post-comment.ts \ + --body "$BODY" \ + --marker "$MARKER" \ + $UPDATE_ONLY \ + --issue-id "$ISSUE_ID" \ + --repository "$GITHUB_REPOSITORY" diff --git a/.github/actions/prepare-test/action.yml b/.github/actions/prepare-test/action.yml index 4c11ec4929..1276aca8eb 100644 --- a/.github/actions/prepare-test/action.yml +++ b/.github/actions/prepare-test/action.yml @@ -36,7 +36,14 @@ runs: set -e # Fail this Action if `gh release list` fails. if [[ "$VERSION" == "nightly" || "$VERSION" == "nightly-latest" ]]; then - echo "tools-url=nightly" >> "$GITHUB_OUTPUT" + if [[ "$USE_ALL_PLATFORM_BUNDLE" == "true" ]]; then + # With `tools: nightly`, the Action downloads the bundle for the runner's platform, so look + # up the latest nightly release here to get its all-platform bundle instead. + tag=$(gh release list --repo dsp-testing/codeql-cli-nightlies --limit 1 --json tagName --jq '.[0].tagName') + echo "tools-url=https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/$tag/codeql-bundle.tar.gz" >> "$GITHUB_OUTPUT" + else + echo "tools-url=nightly" >> "$GITHUB_OUTPUT" + fi exit 0 elif [[ "$VERSION" == "linked" ]]; then echo "tools-url=linked" >> "$GITHUB_OUTPUT" diff --git a/.github/codeql/codeql-config-actions.yml b/.github/codeql/codeql-config-actions.yml new file mode 100644 index 0000000000..dda7a42c16 --- /dev/null +++ b/.github/codeql/codeql-config-actions.yml @@ -0,0 +1,5 @@ +paths-ignore: + - lib + - tests +queries: + - uses: security-and-quality diff --git a/.github/workflows/__all-platform-bundle.yml b/.github/workflows/__all-platform-bundle.yml index 22635a0d14..a2d8c1abb3 100644 --- a/.github/workflows/__all-platform-bundle.yml +++ b/.github/workflows/__all-platform-bundle.yml @@ -92,6 +92,18 @@ jobs: # Swift is not supported on Ubuntu so we manually exclude it from the list here languages: cpp,csharp,go,java,javascript,python,ruby tools: ${{ steps.prepare-test.outputs.tools-url }} + - name: Check that the bundle contains tools for all platforms + env: + CODEQL_PATH: ${{ steps.init.outputs.codeql-path }} + run: | + # Platform-specific bundles only contain the tools for their own platform. + tools_dir="$(dirname "$CODEQL_PATH")/tools" + for platform in linux64 osx64 win64; do + if [[ ! -d "$tools_dir/$platform" ]]; then + echo "::error::Expected an all-platform CodeQL bundle, but '$tools_dir' does not contain a '$platform' directory." + exit 1 + fi + done - name: Build code run: ./build.sh - uses: ./../action/analyze diff --git a/.github/workflows/__linux-arm64.yml b/.github/workflows/__runner-images.yml similarity index 75% rename from .github/workflows/__linux-arm64.yml rename to .github/workflows/__runner-images.yml index 02dab69f9f..8c7ce02f7c 100644 --- a/.github/workflows/__linux-arm64.yml +++ b/.github/workflows/__runner-images.yml @@ -3,7 +3,7 @@ # pr-checks/sync.sh # to regenerate this file. -name: PR Check - Linux Arm64 +name: PR Check - Runner images env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GO111MODULE: auto @@ -47,16 +47,38 @@ defaults: shell: bash concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' || false }} - group: linux-arm64-${{github.ref}}-${{inputs.dotnet-version}}-${{inputs.go-version}} + group: runner-images-${{github.ref}}-${{inputs.dotnet-version}}-${{inputs.go-version}} jobs: - linux-arm64: + runner-images: strategy: fail-fast: false matrix: include: + - os: ubuntu-22.04 + version: linked + - os: ubuntu-22.04-arm + version: linked + - os: ubuntu-24.04 + version: linked - os: ubuntu-24.04-arm - version: nightly-latest - name: Linux Arm64 + version: linked + - os: ubuntu-26.04 + version: linked + - os: ubuntu-26.04-arm + version: linked + - os: windows-2022 + version: linked + - os: windows-2025 + version: linked + - os: macos-15-large + version: linked + - os: macos-15-xlarge + version: linked + - os: macos-26-large + version: linked + - os: macos-26-xlarge + version: linked + name: Runner images if: github.triggering_actor != 'dependabot[bot]' permissions: contents: read @@ -102,5 +124,5 @@ jobs: echo "Found database for $lang" done env: - LANGUAGES: cpp,csharp,go,java,javascript,python,ruby + LANGUAGES: cpp,csharp,go,java,javascript,python,ruby${{ startsWith(matrix.os, 'macos') && ',swift' || '' }} CODEQL_ACTION_TEST_MODE: true diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index efbb246fc9..86741ec455 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -19,70 +19,16 @@ env: CODEQL_ACTION_TESTING_ENVIRONMENT: codeql-action-pr-checks jobs: - # Identify the CodeQL tool versions to use in the analysis job. - check-codeql-versions: + analyze: if: github.triggering_actor != 'dependabot[bot]' runs-on: ubuntu-26.04 - outputs: - versions: ${{ steps.compare.outputs.versions }} - permissions: - contents: read - # We currently need `security-events: read` to access feature flags. - security-events: read - - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Set up default CodeQL bundle - id: setup-default - uses: ./setup-codeql - - name: Set up linked CodeQL bundle - id: setup-linked - uses: ./setup-codeql - with: - tools: linked - - name: Compare default and linked CodeQL bundle versions - id: compare - env: - CODEQL_DEFAULT: ${{ steps.setup-default.outputs.codeql-path }} - CODEQL_LINKED: ${{ steps.setup-linked.outputs.codeql-path }} - run: | - CODEQL_VERSION_DEFAULT="$("$CODEQL_DEFAULT" version --format terse)" - CODEQL_VERSION_LINKED="$("$CODEQL_LINKED" version --format terse)" - echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT" - echo "Linked CodeQL bundle version is $CODEQL_VERSION_LINKED" - - # If we're running on a pull request, run with both bundles, even if `tools: linked` would - # be the same as `tools: null`. This allows us to make the job for each of the bundles a - # required status check. - # - # If we're running on push or schedule, then we can skip running with `tools: linked` when it would be - # the same as running with `tools: null`. - if [[ "$GITHUB_EVENT_NAME" != "pull_request" && "$GITHUB_EVENT_NAME" != "merge_group" && "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LINKED" ]]; then - VERSIONS_JSON='[null]' - else - VERSIONS_JSON='[null, "linked"]' - fi - - # Output a JSON-encoded list with the distinct versions to test against. - echo "Suggested matrix config for analysis job: $VERSIONS_JSON" - echo "versions=${VERSIONS_JSON}" >> $GITHUB_OUTPUT - - analyze-javascript: - if: github.triggering_actor != 'dependabot[bot]' - needs: [check-codeql-versions] strategy: fail-fast: false matrix: - os: - - ubuntu-22.04 - - ubuntu-24.04 - - windows-2022 - - windows-2025 - - macos-14-xlarge - - macos-15-xlarge - tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }} - runs-on: ${{ matrix.os }} + language: + - actions + - javascript permissions: contents: read @@ -95,49 +41,15 @@ jobs: uses: ./init id: init with: - languages: javascript - config-file: ./.github/codeql/codeql-config-javascript.yml - tools: ${{ matrix.tools }} + languages: ${{ matrix.language }} + build-mode: none + config-file: ./.github/codeql/codeql-config-${{ matrix.language }}.yml # confirm steps.init.outputs.codeql-path points to the codeql binary - name: Print CodeQL Version run: > "$CODEQL" version --format=json env: CODEQL: ${{steps.init.outputs.codeql-path}} - - name: Perform CodeQL Analysis - uses: ./analyze - with: - category: "/language:javascript" - upload: ${{ (matrix.os == 'ubuntu-24.04' && !matrix.tools && github.event_name != 'merge_group' && 'always' ) || 'never' }} - - analyze-other: - if: github.triggering_actor != 'dependabot[bot]' - runs-on: ubuntu-26.04 - - strategy: - fail-fast: false - matrix: - include: - - language: actions - - permissions: - contents: read - security-events: write - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Initialize CodeQL - uses: ./init - with: - languages: ${{ matrix.language }} - build-mode: none - config: > - paths-ignore: - - lib - - tests - queries: - - uses: security-and-quality - name: Perform CodeQL Analysis uses: ./analyze with: diff --git a/.github/workflows/deflake.yml b/.github/workflows/deflake.yml index 27024b3780..5a612706e3 100644 --- a/.github/workflows/deflake.yml +++ b/.github/workflows/deflake.yml @@ -31,7 +31,6 @@ on: - "PR Check - C/C\\+\\+: autoinstalling dependencies is skipped (macOS)" - "PR Check - C/C\\+\\+: disabling autoinstalling dependencies (Linux)" - "PR Check - Clean up database cluster directory" - - "PR Check - CodeQL Bundle All" - "PR Check - Config export" - "PR Check - Config input" - "PR Check - Custom source root" @@ -61,6 +60,7 @@ on: - "PR Check - Remote config file" - "PR Check - Resolve environment" - "PR Check - Ruby analysis" + - "PR Check - Runner images" - "PR Check - Rust analysis" - "PR Check - Split workflow" - "PR Check - Start proxy" diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 81d88d1a7d..47d2d73bad 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -95,6 +95,8 @@ jobs: contents: read runs-on: ubuntu-26.04 timeout-minutes: 10 + outputs: + changelog-modified: ${{ steps.changelog-check.outputs.modified }} concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' || false }} @@ -191,6 +193,20 @@ jobs: path: ${{ runner.temp }}/repo-size/ if-no-files-found: error + - name: Check for CHANGELOG.md changes + id: changelog-check + if: steps.fetch-base.outcome == 'success' + env: + BASE_SHA: ${{ steps.fetch-base.outputs.merge_base }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + if ! git diff --exit-code --quiet "$BASE_SHA" "$HEAD_SHA" -- CHANGELOG.md; then + echo "CHANGELOG.md was modified in this PR." + echo "modified=true" >> "$GITHUB_OUTPUT" + else + echo "modified=false" >> "$GITHUB_OUTPUT" + fi + - name: "Backport: Check out base ref" id: checkout-base if: ${{ startsWith(github.head_ref, 'backport-') }} @@ -211,8 +227,8 @@ jobs: exit 1 fi - post-repo-size-comment: - name: Post repo size comment + post-pr-comments: + name: Post PR comments needs: other-checks # Keep write permissions isolated from the job that checks out and tests PR code. This job only # posts the candidate comment body produced by the read-only `pr-checks` job. @@ -232,6 +248,22 @@ jobs: group: check-repo-size-${{ github.event.pull_request.number }} steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # Check out main, not the PR's head, since this job runs with + # `pull-requests: write` permissions and must not execute untrusted code from the PR. + ref: main + + - name: Set up Node.js + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24 + cache: "npm" + + - name: Install dependencies + run: npm ci --workspace=pr-checks --include-workspace-root + - name: Download repo size comment uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: @@ -261,3 +293,42 @@ jobs: else echo "Skipping repo size comment because the delta is below the threshold and no sticky comment exists." fi + + - name: Post a warning about modifying CHANGELOG.md + # Release, backport, mergeback, and bundle-update PRs deliberately modify CHANGELOG.md, + # so skip comment management entirely for these automation flows. + if: >- + needs.other-checks.outputs.changelog-modified == 'true' && + !startsWith(github.event.pull_request.head.ref, 'update-v') && + !startsWith(github.event.pull_request.head.ref, 'backport-v') && + !startsWith(github.event.pull_request.head.ref, 'mergeback/') && + !startsWith(github.event.pull_request.head.ref, 'update-bundle/') + uses: ./.github/actions/post-comment + with: + marker: "post-comment:CHANGELOG.md" + body: | + ⚠️ `CHANGELOG.md` has been modified in this PR. Please do not modify `CHANGELOG.md` directly. + Instead, create a change-note file in `unreleased-change-notes/`. The `CHANGELOG.md` + file will be automatically generated from those change-notes. + See [`unreleased-change-notes/README.md`](https://github.com/github/codeql-action/blob/main/unreleased-change-notes/README.md) for more information. + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Mark the CHANGELOG.md concern as resolved + if: >- + needs.other-checks.outputs.changelog-modified == 'false' && + !startsWith(github.event.pull_request.head.ref, 'update-v') && + !startsWith(github.event.pull_request.head.ref, 'backport-v') && + !startsWith(github.event.pull_request.head.ref, 'mergeback/') && + !startsWith(github.event.pull_request.head.ref, 'update-bundle/') + uses: ./.github/actions/post-comment + with: + marker: "post-comment:CHANGELOG.md" + update-only: true + body: | + ⚠️ `CHANGELOG.md` has been modified in this PR. Please do not modify `CHANGELOG.md` directly. + Instead, create a change-note file in `unreleased-change-notes/`. The `CHANGELOG.md` + file will be automatically generated from those change-notes. + See [`unreleased-change-notes/README.md`](https://github.com/github/codeql-action/blob/main/unreleased-change-notes/README.md) for more information. + + **Edit:** `CHANGELOG.md` is no longer modified in this PR. This concern is resolved. + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-codeql-bundle-all.yml b/.github/workflows/test-codeql-bundle-all.yml deleted file mode 100644 index 9fae4b04a6..0000000000 --- a/.github/workflows/test-codeql-bundle-all.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: "PR Check - CodeQL Bundle All" -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GO111MODULE: auto -on: - push: - branches: - - main - - releases/v* - pull_request: - merge_group: - types: [checks_requested] - schedule: - - cron: "0 5 * * *" - workflow_dispatch: - -concurrency: - cancel-in-progress: ${{ github.event_name == 'pull_request' || false }} - group: ${{ github.workflow }}-${{ github.ref }} - -defaults: - run: - shell: bash -jobs: - test-codeql-bundle-all: - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-26.04 - version: nightly-latest - name: "CodeQL Bundle All" - if: github.triggering_actor != 'dependabot[bot]' - permissions: - contents: read - security-events: read - timeout-minutes: 45 - runs-on: ${{ matrix.os }} - steps: - - name: Check out repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - name: Prepare test - id: prepare-test - uses: ./.github/actions/prepare-test - with: - version: ${{ matrix.version }} - use-all-platform-bundle: true - - name: Install .NET - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 - with: - dotnet-version: "9.x" - - id: init - uses: ./../action/init - with: - # We manually exclude Swift from the languages list here, as it is not supported on Ubuntu - languages: cpp,csharp,go,java,javascript,python,ruby - tools: ${{ steps.prepare-test.outputs.tools-url }} - - name: Build code - run: ./build.sh - - uses: ./../action/analyze - env: - CODEQL_ACTION_TEST_MODE: true diff --git a/CHANGELOG.md b/CHANGELOG.md index fb6d5add0f..b98bfa0a41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs. +## 3.39.4 - 20 Nov 2026 + +- Update default CodeQL bundle version to [2.27.5](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.27.5). [#4333](https://github.com/github/codeql-action/pull/4333) + ## 3.39.3 - 04 Nov 2026 - Fixed diff-informed alert filtering incorrectly removing alerts in changed files whose paths contain spaces, special characters, or non-ASCII characters. [#4283](https://github.com/github/codeql-action/pull/4283) diff --git a/lib/defaults.json b/lib/defaults.json index cfa3f6c1c7..23dd3f7e8e 100644 --- a/lib/defaults.json +++ b/lib/defaults.json @@ -1,6 +1,6 @@ { - "bundleVersion": "codeql-bundle-v2.27.4", - "cliVersion": "2.27.4", - "priorBundleVersion": "codeql-bundle-v2.27.3", - "priorCliVersion": "2.27.3" + "bundleVersion": "codeql-bundle-v2.27.5", + "cliVersion": "2.27.5", + "priorBundleVersion": "codeql-bundle-v2.27.4", + "priorCliVersion": "2.27.4" } diff --git a/lib/entry-points.js b/lib/entry-points.js index b1e1595023..311fe1bea8 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -34203,6 +34203,33 @@ var require_constants6 = __commonJS({ 9007199254740991; var MAX_SAFE_COMPONENT_LENGTH = 16; var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; + var WHITESPACE_CHARACTERS = [ + " ", + "\n", + "\v", + "\f", + "\r", + " ", + "\xA0", + "\u1680", + "\u2000", + "\u2001", + "\u2002", + "\u2003", + "\u2004", + "\u2005", + "\u2006", + "\u2007", + "\u2008", + "\u2009", + "\u200A", + "\u2028", + "\u2029", + "\u202F", + "\u205F", + "\u3000", + "\uFEFF" + ]; var RELEASE_TYPES = [ "major", "premajor", @@ -34217,6 +34244,7 @@ var require_constants6 = __commonJS({ MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_SAFE_INTEGER, + WHITESPACE_CHARACTERS, RELEASE_TYPES, SEMVER_SPEC_VERSION, FLAG_INCLUDE_PRERELEASE: 1, @@ -35117,6 +35145,197 @@ var require_lrucache = __commonJS({ } }); +// node_modules/semver/internal/trim-comparator-whitespace.js +var require_trim_comparator_whitespace = __commonJS({ + "node_modules/semver/internal/trim-comparator-whitespace.js"(exports2, module2) { + "use strict"; + var { + MAX_LENGTH, + MAX_SAFE_BUILD_LENGTH, + WHITESPACE_CHARACTERS + } = require_constants6(); + var whitespace = new Uint8Array(65536); + for (const char of WHITESPACE_CHARACTERS) { + whitespace[char.charCodeAt(0)] = 1; + } + var isWhitespace = (char) => char !== void 0 && whitespace[char.charCodeAt(0)] === 1; + var isVersionPrefix = (char) => char === "v" || char === "=" || isWhitespace(char); + var isDigit = (char) => char !== void 0 && char >= "0" && char <= "9"; + var isLetter = (char) => char !== void 0 && (char >= "a" && char <= "z" || char >= "A" && char <= "Z"); + var isIdentifierCharacter = (char) => isDigit(char) || isLetter(char) || char === "-"; + var isVersionStart = (char) => isDigit(char) || char === "x" || char === "X" || char === "*"; + var findDigitsEndIndex = (range2, start, limit, digitRuns) => { + if (!isDigit(range2[start])) { + return start; + } + if (start >= digitRuns.start && start < digitRuns.end) { + return Math.min(start + limit, digitRuns.end); + } + if (start >= digitRuns.previousStart && start < digitRuns.previousEnd) { + return Math.min(start + limit, digitRuns.previousEnd); + } + let end = start + 1; + while (isDigit(range2[end])) { + end++; + } + digitRuns.previousStart = digitRuns.start; + digitRuns.previousEnd = digitRuns.end; + digitRuns.start = start; + digitRuns.end = end; + return Math.min(start + limit, end); + }; + var findVersionNumberEndIndex = (range2, start, loose, digitRuns) => { + if (!loose && range2[start] === "0") { + return start + 1; + } + return findDigitsEndIndex(range2, start, loose ? MAX_LENGTH : MAX_LENGTH + 1, digitRuns); + }; + var findPrereleaseIdentifierEndIndex = (range2, start, loose, digitRuns) => { + const digitsEnd = findDigitsEndIndex(range2, start, MAX_LENGTH, digitRuns); + if (isLetter(range2[digitsEnd]) || range2[digitsEnd] === "-") { + let end = digitsEnd + 1; + const limit = end + MAX_SAFE_BUILD_LENGTH; + while (end < limit && isIdentifierCharacter(range2[end])) { + end++; + } + return end; + } + return findVersionNumberEndIndex(range2, start, loose, digitRuns); + }; + var findPrereleaseEndIndex = (range2, start, loose, digitRuns) => { + const hyphen = range2[start] === "-"; + if (!loose && !hyphen) { + return start; + } + const identifierStart = start + (hyphen ? 1 : 0); + let end = findPrereleaseIdentifierEndIndex(range2, identifierStart, loose, digitRuns); + if (end === identifierStart) { + if (!loose || !hyphen) { + return start; + } + end = findPrereleaseIdentifierEndIndex(range2, start, loose, digitRuns); + } + while (range2[end] === ".") { + const next = findPrereleaseIdentifierEndIndex(range2, end + 1, loose, digitRuns); + if (next === end + 1) { + break; + } + end = next; + } + return end; + }; + var findBuildIdentifierEndIndex = (range2, start) => { + let end = start; + while (end - start < MAX_SAFE_BUILD_LENGTH && isIdentifierCharacter(range2[end])) { + end++; + } + return end; + }; + var findBuildEndIndex = (range2, start) => { + if (range2[start] !== "+") { + return start; + } + let end = findBuildIdentifierEndIndex(range2, start + 1); + if (end === start + 1) { + return start; + } + while (range2[end] === ".") { + const next = findBuildIdentifierEndIndex(range2, end + 1); + if (next === end + 1) { + break; + } + end = next; + } + return end; + }; + var findLooseFullVersionEndIndex = (range2, start, digitRuns) => { + let end = start; + for (let component = 0; component < 3; component++) { + const next = findVersionNumberEndIndex(range2, end, true, digitRuns); + if (next === end) { + return start; + } + end = next; + if (component < 2) { + if (range2[end] !== ".") { + return start; + } + end++; + } + } + const prereleaseEnd = findPrereleaseEndIndex(range2, end, true, digitRuns); + return findBuildEndIndex(range2, prereleaseEnd); + }; + var findPartialVersionComponentEndIndex = (range2, start, digitRuns) => { + if (isDigit(range2[start])) { + return findVersionNumberEndIndex(range2, start, false, digitRuns); + } + return isVersionStart(range2[start]) ? start + 1 : start; + }; + var findPartialVersionEndIndex = (range2, start, digitRuns) => { + let end = findPartialVersionComponentEndIndex(range2, start, digitRuns); + for (let component = 0; component < 2; component++) { + if (range2[end] !== ".") { + return end; + } + const next = findPartialVersionComponentEndIndex(range2, end + 1, digitRuns); + if (next === end + 1) { + return end; + } + end = next; + } + const prereleaseEnd = findPrereleaseEndIndex(range2, end, false, digitRuns); + return findBuildEndIndex(range2, prereleaseEnd); + }; + var findVersionEndIndex = (range2, start, digitRuns) => { + const fullVersionEnd = findLooseFullVersionEndIndex(range2, start, digitRuns); + return fullVersionEnd !== start ? fullVersionEnd : findPartialVersionEndIndex(range2, start, digitRuns); + }; + var findRemovableWhitespaceIndex = (range2, matchStart) => { + let position = matchStart; + if (isWhitespace(range2[position])) { + position++; + } + if (range2[position] === "<" || range2[position] === ">") { + position++; + } + if (range2[position] === "=") { + position++; + } + return isWhitespace(range2[position]) ? position : -1; + }; + var trimComparatorWhitespace = (range2) => { + let result = ""; + let copyFrom = 0; + let cursor = 0; + const digitRuns = { start: -1, end: -1, previousStart: -1, previousEnd: -1 }; + while (cursor < range2.length) { + const matchStart = cursor; + if (range2[cursor] === "<" || range2[cursor] === ">") { + cursor++; + } else if (!isVersionPrefix(range2[cursor]) && !isVersionStart(range2[cursor])) { + cursor++; + continue; + } + while (cursor < range2.length && isVersionPrefix(range2[cursor])) { + cursor++; + } + if (!isVersionStart(range2[cursor])) { + continue; + } + const whitespacePosition = findRemovableWhitespaceIndex(range2, matchStart); + if (whitespacePosition !== -1) { + result += range2.slice(copyFrom, whitespacePosition); + copyFrom = whitespacePosition + 1; + } + cursor = findVersionEndIndex(range2, cursor, digitRuns); + } + return result + range2.slice(copyFrom); + }; + module2.exports = trimComparatorWhitespace; + } +}); + // node_modules/semver/classes/range.js var require_range = __commonJS({ "node_modules/semver/classes/range.js"(exports2, module2) { @@ -35198,7 +35417,7 @@ var require_range = __commonJS({ const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]; range2 = range2.replace(hr, hyphenReplace(this.options.includePrerelease)); debug6("hyphen replace", range2); - range2 = range2.replace(re[t.COMPARATORTRIM], comparatorTrimReplace); + range2 = trimComparatorWhitespace(range2); debug6("comparator trim", range2); range2 = range2.replace(re[t.TILDETRIM], tildeTrimReplace); debug6("tilde trim", range2); @@ -35268,11 +35487,11 @@ var require_range = __commonJS({ var Comparator = require_comparator(); var debug6 = require_debug(); var SemVer = require_semver(); + var trimComparatorWhitespace = require_trim_comparator_whitespace(); var { safeRe: re, src, t, - comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re(); @@ -54591,103 +54810,90 @@ var require_fxp = __commonJS({ }, o: (t2, e2) => Object.prototype.hasOwnProperty.call(t2, e2), r: (t2) => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t2, "__esModule", { value: true }); } }, e = {}; - t.r(e), t.d(e, { XMLBuilder: () => Bt, XMLParser: () => Tt, XMLValidator: () => Ut }); - const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"); - function s(t2, e2) { - const n2 = []; - let i2 = e2.exec(t2); - for (; i2; ) { - const s2 = []; - s2.startIndex = e2.lastIndex - i2[0].length; - const r2 = i2.length; - for (let t3 = 0; t3 < r2; t3++) s2.push(i2[t3]); - n2.push(s2), i2 = e2.exec(t2); - } - return n2; - } - const r = function(t2) { + t.r(e), t.d(e, { XMLBuilder: () => $e, XMLParser: () => ce, XMLValidator: () => Oe }); + const n = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = new RegExp("^[" + n + "][" + n + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"), r = function(t2) { return !(null == i.exec(t2)); - }, o = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], a = ["__proto__", "constructor", "prototype"], h = { allowBooleanAttributes: false, unpairedTags: [] }; + }, s = ["hasOwnProperty", "toString", "valueOf", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"], o = ["__proto__", "constructor", "prototype"], a = { allowBooleanAttributes: false, unpairedTags: [] }; function l(t2, e2) { - e2 = Object.assign({}, h, e2); + e2 = Object.assign({}, a, e2); const n2 = []; - let i2 = false, s2 = false; + let i2 = false, r2 = false; "\uFEFF" === t2[0] && (t2 = t2.substr(1)); - for (let r2 = 0; r2 < t2.length; r2++) if ("<" === t2[r2] && "?" === t2[r2 + 1]) { - if (r2 += 2, r2 = p(t2, r2), r2.err) return r2; + for (let s2 = 0; s2 < t2.length; s2++) if ("<" === t2[s2] && "?" === t2[s2 + 1]) { + if (s2 += 2, s2 = p(t2, s2), s2.err) return s2; } else { - if ("<" !== t2[r2]) { - if (u(t2[r2])) continue; - return b("InvalidChar", "char '" + t2[r2] + "' is not expected.", w(t2, r2)); + if ("<" !== t2[s2]) { + if (c(t2[s2])) continue; + return x("InvalidChar", "char '" + t2[s2] + "' is not expected.", N(t2, s2)); } { - let o2 = r2; - if (r2++, "!" === t2[r2]) { - r2 = c(t2, r2); + let o2 = s2; + if (s2++, "!" === t2[s2]) { + s2 = h(t2, s2); continue; } { let a2 = false; - "/" === t2[r2] && (a2 = true, r2++); - let h2 = ""; - for (; r2 < t2.length && ">" !== t2[r2] && " " !== t2[r2] && " " !== t2[r2] && "\n" !== t2[r2] && "\r" !== t2[r2]; r2++) h2 += t2[r2]; - if (h2 = h2.trim(), "/" === h2[h2.length - 1] && (h2 = h2.substring(0, h2.length - 1), r2--), !E(h2)) { + "/" === t2[s2] && (a2 = true, s2++); + let l2 = ""; + for (; s2 < t2.length && ">" !== t2[s2] && " " !== t2[s2] && " " !== t2[s2] && "\n" !== t2[s2] && "\r" !== t2[s2]; s2++) l2 += t2[s2]; + if (l2 = l2.trim(), "/" === l2[l2.length - 1] && (l2 = l2.substring(0, l2.length - 1), s2--), !y(l2)) { let e3; - return e3 = 0 === h2.trim().length ? "Invalid space after '<'." : "Tag '" + h2 + "' is an invalid name.", b("InvalidTag", e3, w(t2, r2)); - } - const l2 = g(t2, r2); - if (false === l2) return b("InvalidAttr", "Attributes for '" + h2 + "' have open quote.", w(t2, r2)); - let d2 = l2.value; - if (r2 = l2.index, "/" === d2[d2.length - 1]) { - const n3 = r2 - d2.length; - d2 = d2.substring(0, d2.length - 1); - const s3 = x(d2, e2); - if (true !== s3) return b(s3.err.code, s3.err.msg, w(t2, n3 + s3.err.line)); + return e3 = 0 === l2.trim().length ? "Invalid space after '<'." : "Tag '" + l2 + "' is an invalid name.", x("InvalidTag", e3, N(t2, s2)); + } + const d2 = f(t2, s2); + if (false === d2) return x("InvalidAttr", "Attributes for '" + l2 + "' have open quote.", N(t2, s2)); + let u2 = d2.value; + if (s2 = d2.index, "/" === u2[u2.length - 1]) { + const n3 = s2 - u2.length; + u2 = u2.substring(0, u2.length - 1); + const r3 = g(u2, e2); + if (true !== r3) return x(r3.err.code, r3.err.msg, N(t2, n3 + r3.err.line)); i2 = true; } else if (a2) { - if (!l2.tagClosed) return b("InvalidTag", "Closing tag '" + h2 + "' doesn't have proper closing.", w(t2, r2)); - if (d2.trim().length > 0) return b("InvalidTag", "Closing tag '" + h2 + "' can't have attributes or invalid starting.", w(t2, o2)); - if (0 === n2.length) return b("InvalidTag", "Closing tag '" + h2 + "' has not been opened.", w(t2, o2)); + if (!d2.tagClosed) return x("InvalidTag", "Closing tag '" + l2 + "' doesn't have proper closing.", N(t2, s2)); + if (u2.trim().length > 0) return x("InvalidTag", "Closing tag '" + l2 + "' can't have attributes or invalid starting.", N(t2, o2)); + if (0 === n2.length) return x("InvalidTag", "Closing tag '" + l2 + "' has not been opened.", N(t2, o2)); { const e3 = n2.pop(); - if (h2 !== e3.tagName) { - let n3 = w(t2, e3.tagStartPos); - return b("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + h2 + "'.", w(t2, o2)); + if (l2 !== e3.tagName) { + let n3 = N(t2, e3.tagStartPos); + return x("InvalidTag", "Expected closing tag '" + e3.tagName + "' (opened in line " + n3.line + ", col " + n3.col + ") instead of closing tag '" + l2 + "'.", N(t2, o2)); } - 0 == n2.length && (s2 = true); + 0 == n2.length && (r2 = true); } } else { - const a3 = x(d2, e2); - if (true !== a3) return b(a3.err.code, a3.err.msg, w(t2, r2 - d2.length + a3.err.line)); - if (true === s2) return b("InvalidXml", "Multiple possible root nodes found.", w(t2, r2)); - -1 !== e2.unpairedTags.indexOf(h2) || n2.push({ tagName: h2, tagStartPos: o2 }), i2 = true; - } - for (r2++; r2 < t2.length; r2++) if ("<" === t2[r2]) { - if ("!" === t2[r2 + 1]) { - r2++, r2 = c(t2, r2); + const a3 = g(u2, e2); + if (true !== a3) return x(a3.err.code, a3.err.msg, N(t2, s2 - u2.length + a3.err.line)); + if (true === r2) return x("InvalidXml", "Multiple possible root nodes found.", N(t2, s2)); + -1 !== e2.unpairedTags.indexOf(l2) || n2.push({ tagName: l2, tagStartPos: o2 }), i2 = true; + } + for (s2++; s2 < t2.length; s2++) if ("<" === t2[s2]) { + if ("!" === t2[s2 + 1]) { + s2++, s2 = h(t2, s2); continue; } - if ("?" !== t2[r2 + 1]) break; - if (r2 = p(t2, ++r2), r2.err) return r2; - } else if ("&" === t2[r2]) { - const e3 = N(t2, r2); - if (-1 == e3) return b("InvalidChar", "char '&' is not expected.", w(t2, r2)); - r2 = e3; - } else if (true === s2 && !u(t2[r2])) return b("InvalidXml", "Extra text at the end", w(t2, r2)); - "<" === t2[r2] && r2--; + if ("?" !== t2[s2 + 1]) break; + if (s2 = p(t2, ++s2), s2.err) return s2; + } else if ("&" === t2[s2]) { + const e3 = m(t2, s2); + if (-1 == e3) return x("InvalidChar", "char '&' is not expected.", N(t2, s2)); + s2 = e3; + } else if (true === r2 && !c(t2[s2])) return x("InvalidXml", "Extra text at the end", N(t2, s2)); + "<" === t2[s2] && s2--; } } } - return i2 ? 1 == n2.length ? b("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", w(t2, n2[0].tagStartPos)) : !(n2.length > 0) || b("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : b("InvalidXml", "Start tag expected.", 1); + return i2 ? 1 == n2.length ? x("InvalidTag", "Unclosed tag '" + n2[0].tagName + "'.", N(t2, n2[0].tagStartPos)) : !(n2.length > 0) || x("InvalidXml", "Invalid '" + JSON.stringify(n2.map((t3) => t3.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 }) : x("InvalidXml", "Start tag expected.", 1); } - function u(t2) { + function c(t2) { return " " === t2 || " " === t2 || "\n" === t2 || "\r" === t2; } function p(t2, e2) { const n2 = e2; for (; e2 < t2.length; e2++) if ("?" == t2[e2] || " " == t2[e2]) { const i2 = t2.substr(n2, e2 - n2); - if (e2 > 5 && "xml" === i2) return b("InvalidXml", "XML declaration allowed only at the start of the document.", w(t2, e2)); + if (e2 > 5 && "xml" === i2) return x("InvalidXml", "XML declaration allowed only at the start of the document.", N(t2, e2)); if ("?" == t2[e2] && ">" == t2[e2 + 1]) { e2++; break; @@ -54696,7 +54902,7 @@ var require_fxp = __commonJS({ } return e2; } - function c(t2, e2) { + function h(t2, e2) { if (t2.length > e2 + 5 && "-" === t2[e2 + 1] && "-" === t2[e2 + 2]) { for (e2 += 3; e2 < t2.length; e2++) if ("-" === t2[e2] && "-" === t2[e2 + 1] && ">" === t2[e2 + 2]) { e2 += 2; @@ -54714,34 +54920,60 @@ var require_fxp = __commonJS({ } return e2; } - const d = '"', f = "'"; - function g(t2, e2) { - let n2 = "", i2 = "", s2 = false; + const d = '"', u = "'"; + function f(t2, e2) { + let n2 = "", i2 = "", r2 = false; for (; e2 < t2.length; e2++) { - if (t2[e2] === d || t2[e2] === f) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); + if (t2[e2] === d || t2[e2] === u) "" === i2 ? i2 = t2[e2] : i2 !== t2[e2] || (i2 = ""); else if (">" === t2[e2] && "" === i2) { - s2 = true; + r2 = true; break; } n2 += t2[e2]; } - return "" === i2 && { value: n2, index: e2, tagClosed: s2 }; + return "" === i2 && { value: n2, index: e2, tagClosed: r2 }; } - const m = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g"); - function x(t2, e2) { - const n2 = s(t2, m), i2 = {}; + function g(t2, e2) { + const n2 = (function(t3) { + const e3 = [], n3 = t3.length; + let i3 = 0; + for (; i3 < n3; ) { + const r2 = i3; + for (; i3 < n3 && c(t3[i3]); ) i3++; + if (i3 >= n3) break; + if ("=" === t3[i3]) { + i3++; + continue; + } + const s2 = t3.slice(r2, i3), o2 = i3; + for (; i3 < n3 && !c(t3[i3]) && "=" !== t3[i3]; ) i3++; + const a2 = t3.slice(o2, i3); + let l2, p2, h2, d2 = i3; + for (; d2 < n3 && c(t3[d2]); ) d2++; + d2 < n3 && "=" === t3[d2] && (l2 = t3.slice(i3, d2 + 1), i3 = d2 + 1); + let u2 = i3; + for (; u2 < n3 && c(t3[u2]); ) u2++; + if (u2 < n3 && ('"' === t3[u2] || "'" === t3[u2])) { + const e4 = u2 + 1, n4 = t3.indexOf(t3[u2], e4); + -1 !== n4 && (p2 = t3[u2], h2 = t3.slice(e4, n4), i3 = n4 + 1); + } + const f2 = { startIndex: r2 }; + f2[1] = s2, f2[2] = a2, f2[3] = l2, f2[4] = void 0 !== p2 || void 0, f2[5] = p2, f2[6] = h2, e3.push(f2); + } + return e3; + })(t2), i2 = {}; for (let t3 = 0; t3 < n2.length; t3++) { - if (0 === n2[t3][1].length) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", v(n2[t3])); - if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return b("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", v(n2[t3])); - if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return b("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", v(n2[t3])); - const s2 = n2[t3][2]; - if (!y(s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is an invalid name.", v(n2[t3])); - if (Object.prototype.hasOwnProperty.call(i2, s2)) return b("InvalidAttr", "Attribute '" + s2 + "' is repeated.", v(n2[t3])); - i2[s2] = 1; + if (0 === n2[t3][1].length) return x("InvalidAttr", "Attribute '" + n2[t3][2] + "' has no space in starting.", E(n2[t3])); + if (void 0 !== n2[t3][3] && void 0 === n2[t3][4]) return x("InvalidAttr", "Attribute '" + n2[t3][2] + "' is without value.", E(n2[t3])); + if (void 0 === n2[t3][3] && !e2.allowBooleanAttributes) return x("InvalidAttr", "boolean attribute '" + n2[t3][2] + "' is not allowed.", E(n2[t3])); + const r2 = n2[t3][2]; + if (!b(r2)) return x("InvalidAttr", "Attribute '" + r2 + "' is an invalid name.", E(n2[t3])); + if (Object.prototype.hasOwnProperty.call(i2, r2)) return x("InvalidAttr", "Attribute '" + r2 + "' is repeated.", E(n2[t3])); + i2[r2] = 1; } return true; } - function N(t2, e2) { + function m(t2, e2) { if (";" === t2[++e2]) return -1; if ("#" === t2[e2]) return (function(t3, e3) { let n3 = /\d/; @@ -54758,46 +54990,46 @@ var require_fxp = __commonJS({ } return e2; } - function b(t2, e2, n2) { + function x(t2, e2, n2) { return { err: { code: t2, msg: e2, line: n2.line || n2, col: n2.col } }; } - function y(t2) { + function b(t2) { return r(t2); } - function E(t2) { + function y(t2) { return r(t2); } - function w(t2, e2) { + function N(t2, e2) { const n2 = t2.substring(0, e2).split(/\r?\n/); return { line: n2.length, col: n2[n2.length - 1].length + 1 }; } - function v(t2) { + function E(t2) { return t2.startIndex + t2[1].length; } - const S = (t2) => o.includes(t2) ? "__" + t2 : t2, _2 = { preserveOrder: false, attributeNamePrefix: "@_", attributesGroupName: false, textNodeName: "#text", ignoreAttributes: true, removeNSPrefix: false, allowBooleanAttributes: false, parseTagValue: true, parseAttributeValue: false, trimValues: true, cdataPropName: false, numberParseOptions: { hex: true, leadingZeros: true, eNotation: true }, tagValueProcessor: function(t2, e2) { + const w = (t2) => s.includes(t2) ? "__" + t2 : t2, v = { 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(t2, e2) { return e2; }, attributeValueProcessor: function(t2, e2) { return e2; }, stopNodes: [], alwaysCreateTextNode: false, isArray: () => false, commentPropName: false, unpairedTags: [], processEntities: true, htmlEntities: false, entityDecoder: null, ignoreDeclaration: false, ignorePiTags: false, transformTagName: false, transformAttributeName: false, updateTag: function(t2, e2, n2) { return t2; - }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: S }; - function A(t2, e2) { + }, captureMetaData: false, maxNestedTags: 100, strictReservedNames: true, jPath: true, onDangerousProperty: w }; + function S(t2, e2) { if ("string" != typeof t2) return; const n2 = t2.toLowerCase(); + if (s.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); if (o.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); - if (a.some((t3) => n2 === t3.toLowerCase())) throw new Error(`[SECURITY] Invalid ${e2}: "${t2}" is a reserved JavaScript keyword that could cause prototype pollution`); } - function T(t2, e2) { - return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : T(true); + function A(t2, e2) { + return "boolean" == typeof t2 ? { enabled: t2, maxEntitySize: 1e4, maxExpansionDepth: 1e4, maxTotalExpansions: 1 / 0, maxExpandedLength: 1e5, maxEntityCount: 1e3, allowedTags: null, tagFilter: null, appliesTo: "all" } : "object" == typeof t2 && null !== t2 ? { enabled: false !== t2.enabled, maxEntitySize: Math.max(1, t2.maxEntitySize ?? 1e4), maxExpansionDepth: Math.max(1, t2.maxExpansionDepth ?? 1e4), maxTotalExpansions: Math.max(1, t2.maxTotalExpansions ?? 1 / 0), maxExpandedLength: Math.max(1, t2.maxExpandedLength ?? 1e5), maxEntityCount: Math.max(1, t2.maxEntityCount ?? 1e3), allowedTags: t2.allowedTags ?? null, tagFilter: t2.tagFilter ?? null, appliesTo: t2.appliesTo ?? "all" } : A(true); } - const C = function(t2) { - const e2 = Object.assign({}, _2, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; - for (const { value: t3, name: e3 } of n2) t3 && A(t3, e3); - return null === e2.onDangerousProperty && (e2.onDangerousProperty = S), e2.processEntities = T(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; + const T = function(t2) { + const e2 = Object.assign({}, v, t2), n2 = [{ value: e2.attributeNamePrefix, name: "attributeNamePrefix" }, { value: e2.attributesGroupName, name: "attributesGroupName" }, { value: e2.textNodeName, name: "textNodeName" }, { value: e2.cdataPropName, name: "cdataPropName" }, { value: e2.commentPropName, name: "commentPropName" }]; + for (const { value: t3, name: e3 } of n2) t3 && S(t3, e3); + return null === e2.onDangerousProperty && (e2.onDangerousProperty = w), e2.processEntities = A(e2.processEntities, e2.htmlEntities), e2.unpairedTagsSet = new Set(e2.unpairedTags), e2.stopNodes && Array.isArray(e2.stopNodes) && (e2.stopNodes = e2.stopNodes.map((t3) => "string" == typeof t3 && t3.startsWith("*.") ? ".." + t3.substring(2) : t3)), e2; }; - let P; - P = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); - class O { + let _2; + _2 = "function" != typeof Symbol ? "@@xmlMetadata" : /* @__PURE__ */ Symbol("XML Node Metadata"); + class C { constructor(t2) { this.tagname = t2, this.child = [], this[":@"] = /* @__PURE__ */ Object.create(null); } @@ -54805,15 +55037,42 @@ var require_fxp = __commonJS({ "__proto__" === t2 && (t2 = "#__proto__"), this.child.push({ [t2]: e2 }); } addChild(t2, e2) { - "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), void 0 !== e2 && (this.child[this.child.length - 1][P] = { startIndex: e2 }); + "__proto__" === t2.tagname && (t2.tagname = "#__proto__"), t2[":@"] && Object.keys(t2[":@"]).length > 0 ? this.child.push({ [t2.tagname]: t2.child, ":@": t2[":@"] }) : this.child.push({ [t2.tagname]: t2.child }), this.addStartIndex(e2); + } + addStartIndex(t2) { + void 0 !== t2 && (this.child[this.child.length - 1][_2] = { startIndex: t2 }); + } + addEndIndex(t2) { + const e2 = this.child[this.child.length - 1]; + void 0 !== e2 && void 0 !== e2[_2] && void 0 === e2[_2].endIndex && (e2[_2].endIndex = t2); } static getMetaDataSymbol() { - return P; + return _2; + } + } + const $ = ":A-Za-z_\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD", O = ":A-Za-z_\xC0-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}", P = O + "\\-\\.\\d\xB7\u0300-\u036F\u0487\u203F-\u2040", j = (t2, e2, n2 = "") => { + const i2 = `[${t2.replace(":", "")}][${e2.replace(":", "")}]*`; + return { name: new RegExp(`^[${t2}][${e2}]*$`, n2), ncName: new RegExp(`^${i2}$`, n2), qName: new RegExp(`^${i2}(?::${i2})?$`, n2), nmToken: new RegExp(`^[${e2}]+$`, n2), nmTokens: new RegExp(`^[${e2}]+(?:\\s+[${e2}]+)*$`, n2) }; + }, I = j($, $ + "\\-\\.\\d\xB7\u0300-\u036F\u203F-\u2040"), k = j(O, P, "u"), L = ":A-Za-z_", D = j(L, L + "\\-\\.\\d"), M = (t2 = "1.0", e2 = false) => e2 ? D : "1.1" === t2 ? k : I, R = (t2, { xmlVersion: e2 = "1.0", asciiOnly: n2 = false } = {}) => M(e2, n2).qName.test(t2), V = ["name", "ncName", "qName", "nmToken", "nmTokens"], q = (t2, { xmlVersion: e2 = "1.0", asciiOnly: n2 = false, maxCacheSize: i2 = 2048 } = {}) => { + if (!V.includes(t2)) throw new TypeError(`Unknown production "${t2}". Must be one of: ${V.join(", ")}`); + const r2 = M(e2, n2)[t2]; + let s2 = /* @__PURE__ */ new Map(); + const o2 = (t3) => { + const e3 = s2.get(t3); + if (void 0 !== e3) return e3; + const n3 = r2.test(t3); + return s2.size < i2 && s2.set(t3, n3), n3; + }; + return o2.reset = () => { + s2 = /* @__PURE__ */ new Map(); + }, o2; + }; + class F { + constructor(t2, e2) { + this.suppressValidationErr = !t2, this.options = t2, this.xmlVersion = e2 || 1; } - } - class $ { - constructor(t2) { - this.suppressValidationErr = !t2, this.options = t2; + setXmlVersion(t2 = 1) { + this.xmlVersion = t2; } readDocType(t2, e2) { const n2 = /* @__PURE__ */ Object.create(null); @@ -54821,134 +55080,277 @@ var require_fxp = __commonJS({ if ("O" !== t2[e2 + 3] || "C" !== t2[e2 + 4] || "T" !== t2[e2 + 5] || "Y" !== t2[e2 + 6] || "P" !== t2[e2 + 7] || "E" !== t2[e2 + 8]) throw new Error("Invalid Tag instead of DOCTYPE"); { e2 += 9; - let s2 = 1, r2 = false, o2 = false, a2 = ""; - for (; e2 < t2.length; e2++) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { - if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, s2--) : s2--, 0 === s2) break; - } else "[" === t2[e2] ? r2 = true : a2 += t2[e2]; + let r2 = 1, s2 = false, o2 = false, a2 = null, l2 = ""; + for (; e2 < t2.length; e2++) if (null === a2) if (s2 || o2 || '"' !== t2[e2] && "'" !== t2[e2]) if ("<" !== t2[e2] || o2) if (">" === t2[e2]) { + if (o2 ? "-" === t2[e2 - 1] && "-" === t2[e2 - 2] && (o2 = false, r2--) : r2--, 0 === r2) break; + } else "[" === t2[e2] ? s2 = true : l2 += t2[e2]; else { - if (r2 && D(t2, "!ENTITY", e2)) { - let s3, r3; - if (e2 += 7, [s3, r3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === r3.indexOf("&")) { + if (s2 && B(t2, "!ENTITY", e2)) { + let r3, s3; + if (e2 += 7, [r3, s3, e2] = this.readEntityExp(t2, e2 + 1, this.suppressValidationErr), -1 === s3.indexOf("&")) { if (false !== this.options.enabled && null != this.options.maxEntityCount && i2 >= this.options.maxEntityCount) throw new Error(`Entity count (${i2 + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`); - n2[s3] = r3, i2++; + n2[r3] = s3, i2++; } - } else if (r2 && D(t2, "!ELEMENT", e2)) { + } else if (s2 && B(t2, "!ELEMENT", e2)) { e2 += 8; const { index: n3 } = this.readElementExp(t2, e2 + 1); e2 = n3; - } else if (r2 && D(t2, "!ATTLIST", e2)) e2 += 8; - else if (r2 && D(t2, "!NOTATION", e2)) { + } else if (s2 && B(t2, "!ATTLIST", e2)) e2 += 8; + else if (s2 && B(t2, "!NOTATION", e2)) { e2 += 9; const { index: n3 } = this.readNotationExp(t2, e2 + 1, this.suppressValidationErr); e2 = n3; } else { - if (!D(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); + if (!B(t2, "!--", e2)) throw new Error("Invalid DOCTYPE"); o2 = true; } - s2++, a2 = ""; + r2++, l2 = ""; } - if (0 !== s2) throw new Error("Unclosed DOCTYPE"); + else a2 = t2[e2], l2 += t2[e2]; + else t2[e2] === a2 && (a2 = null), l2 += t2[e2]; + if (null !== a2 || 0 !== r2) throw new Error("Unclosed DOCTYPE"); } return { entities: n2, i: e2 }; } readEntityExp(t2, e2) { - const n2 = e2 = I(t2, e2); + const n2 = e2 = U(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]) && '"' !== t2[e2] && "'" !== t2[e2]; ) e2++; let i2 = t2.substring(n2, e2); - if (M(i2), e2 = I(t2, e2), !this.suppressValidationErr) { + if (G(i2, { xmlVersion: this.xmlVersion }), e2 = U(t2, e2), !this.suppressValidationErr) { if ("SYSTEM" === t2.substring(e2, e2 + 6).toUpperCase()) throw new Error("External entities are not supported"); if ("%" === t2[e2]) throw new Error("Parameter entities are not supported"); } - let s2 = ""; - if ([e2, s2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && s2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${s2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); - return [i2, s2, --e2]; + let r2 = ""; + if ([e2, r2] = this.readIdentifierVal(t2, e2, "entity"), false !== this.options.enabled && null != this.options.maxEntitySize && r2.length > this.options.maxEntitySize) throw new Error(`Entity "${i2}" size (${r2.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`); + return [i2, r2, --e2]; } readNotationExp(t2, e2) { - const n2 = e2 = I(t2, e2); + const n2 = e2 = U(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; let i2 = t2.substring(n2, e2); - !this.suppressValidationErr && M(i2), e2 = I(t2, e2); - const s2 = t2.substring(e2, e2 + 6).toUpperCase(); - if (!this.suppressValidationErr && "SYSTEM" !== s2 && "PUBLIC" !== s2) throw new Error(`Expected SYSTEM or PUBLIC, found "${s2}"`); - e2 += s2.length, e2 = I(t2, e2); - let r2 = null, o2 = null; - if ("PUBLIC" === s2) [e2, r2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = I(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); - else if ("SYSTEM" === s2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); - return { notationName: i2, publicIdentifier: r2, systemIdentifier: o2, index: --e2 }; + !this.suppressValidationErr && G(i2, { xmlVersion: this.xmlVersion }), e2 = U(t2, e2); + const r2 = t2.substring(e2, e2 + 6).toUpperCase(); + if (!this.suppressValidationErr && "SYSTEM" !== r2 && "PUBLIC" !== r2) throw new Error(`Expected SYSTEM or PUBLIC, found "${r2}"`); + e2 += r2.length, e2 = U(t2, e2); + let s2 = null, o2 = null; + if ("PUBLIC" === r2) [e2, s2] = this.readIdentifierVal(t2, e2, "publicIdentifier"), '"' !== t2[e2 = U(t2, e2)] && "'" !== t2[e2] || ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier")); + else if ("SYSTEM" === r2 && ([e2, o2] = this.readIdentifierVal(t2, e2, "systemIdentifier"), !this.suppressValidationErr && !o2)) throw new Error("Missing mandatory system identifier for SYSTEM notation"); + return { notationName: i2, publicIdentifier: s2, systemIdentifier: o2, index: --e2 }; } readIdentifierVal(t2, e2, n2) { let i2 = ""; - const s2 = t2[e2]; - if ('"' !== s2 && "'" !== s2) throw new Error(`Expected quoted string, found "${s2}"`); - const r2 = ++e2; - for (; e2 < t2.length && t2[e2] !== s2; ) e2++; - if (i2 = t2.substring(r2, e2), t2[e2] !== s2) throw new Error(`Unterminated ${n2} value`); + const r2 = t2[e2]; + if ('"' !== r2 && "'" !== r2) throw new Error(`Expected quoted string, found "${r2}"`); + const s2 = ++e2; + for (; e2 < t2.length && t2[e2] !== r2; ) e2++; + if (i2 = t2.substring(s2, e2), t2[e2] !== r2) throw new Error(`Unterminated ${n2} value`); return [++e2, i2]; } readElementExp(t2, e2) { - const n2 = e2 = I(t2, e2); + const n2 = e2 = U(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; let i2 = t2.substring(n2, e2); - if (!this.suppressValidationErr && !r(i2)) throw new Error(`Invalid element name: "${i2}"`); - let s2 = ""; - if ("E" === t2[e2 = I(t2, e2)] && D(t2, "MPTY", e2)) e2 += 4; - else if ("A" === t2[e2] && D(t2, "NY", e2)) e2 += 2; + if (!this.suppressValidationErr && !R(i2, { xmlVersion: this.xmlVersion })) throw new Error(`Invalid element name: "${i2}"`); + let r2 = ""; + if ("E" === t2[e2 = U(t2, e2)] && B(t2, "MPTY", e2)) e2 += 4; + else if ("A" === t2[e2] && B(t2, "NY", e2)) e2 += 2; else if ("(" === t2[e2]) { const n3 = ++e2; for (; e2 < t2.length && ")" !== t2[e2]; ) e2++; - if (s2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); + if (r2 = t2.substring(n3, e2), ")" !== t2[e2]) throw new Error("Unterminated content model"); } else if (!this.suppressValidationErr) throw new Error(`Invalid Element Expression, found "${t2[e2]}"`); - return { elementName: i2, contentModel: s2.trim(), index: e2 }; + return { elementName: i2, contentModel: r2.trim(), index: e2 }; } readAttlistExp(t2, e2) { - let n2 = e2 = I(t2, e2); + let n2 = e2 = U(t2, e2); for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; let i2 = t2.substring(n2, e2); - for (M(i2), n2 = e2 = I(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - let s2 = t2.substring(n2, e2); - if (!M(s2)) throw new Error(`Invalid attribute name: "${s2}"`); - e2 = I(t2, e2); - let r2 = ""; + for (G(i2, { xmlVersion: this.xmlVersion }), n2 = e2 = U(t2, e2); e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; + let r2 = t2.substring(n2, e2); + if (!G(r2, { xmlVersion: this.xmlVersion })) throw new Error(`Invalid attribute name: "${r2}"`); + e2 = U(t2, e2); + let s2 = ""; if ("NOTATION" === t2.substring(e2, e2 + 8).toUpperCase()) { - if (r2 = "NOTATION", "(" !== t2[e2 = I(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); + if (s2 = "NOTATION", "(" !== t2[e2 = U(t2, e2 += 8)]) throw new Error(`Expected '(', found "${t2[e2]}"`); e2++; let n3 = []; for (; e2 < t2.length && ")" !== t2[e2]; ) { const i3 = e2; for (; e2 < t2.length && "|" !== t2[e2] && ")" !== t2[e2]; ) e2++; - let s3 = t2.substring(i3, e2); - if (s3 = s3.trim(), !M(s3)) throw new Error(`Invalid notation name: "${s3}"`); - n3.push(s3), "|" === t2[e2] && (e2++, e2 = I(t2, e2)); + let r3 = t2.substring(i3, e2); + if (r3 = r3.trim(), !G(r3, { xmlVersion: this.xmlVersion })) throw new Error(`Invalid notation name: "${r3}"`); + n3.push(r3), "|" === t2[e2] && (e2++, e2 = U(t2, e2)); } if (")" !== t2[e2]) throw new Error("Unterminated list of notations"); - e2++, r2 += " (" + n3.join("|") + ")"; + e2++, s2 += " (" + n3.join("|") + ")"; } else { const n3 = e2; for (; e2 < t2.length && !/\s/.test(t2[e2]); ) e2++; - r2 += t2.substring(n3, e2); + s2 += t2.substring(n3, e2); const i3 = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"]; - if (!this.suppressValidationErr && !i3.includes(r2.toUpperCase())) throw new Error(`Invalid attribute type: "${r2}"`); + if (!this.suppressValidationErr && !i3.includes(s2.toUpperCase())) throw new Error(`Invalid attribute type: "${s2}"`); } - e2 = I(t2, e2); + e2 = U(t2, e2); let o2 = ""; - return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: s2, attributeType: r2, defaultValue: o2, index: e2 }; + return "#REQUIRED" === t2.substring(e2, e2 + 8).toUpperCase() ? (o2 = "#REQUIRED", e2 += 8) : "#IMPLIED" === t2.substring(e2, e2 + 7).toUpperCase() ? (o2 = "#IMPLIED", e2 += 7) : [e2, o2] = this.readIdentifierVal(t2, e2, "ATTLIST"), { elementName: i2, attributeName: r2, attributeType: s2, defaultValue: o2, index: e2 }; } } - const I = (t2, e2) => { + const U = (t2, e2) => { for (; e2 < t2.length && /\s/.test(t2[e2]); ) e2++; return e2; }; - function D(t2, e2, n2) { + function B(t2, e2, n2) { for (let i2 = 0; i2 < e2.length; i2++) if (e2[i2] !== t2[n2 + i2 + 1]) return false; return true; } - function M(t2) { - if (r(t2)) return t2; + function G(t2, e2) { + if (R(t2, { xmlVersion: e2 })) return t2; throw new Error(`Invalid entity name ${t2}`); } - const j = /^[-+]?0x[a-fA-F0-9]+$/, V = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, L = { hex: true, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original" }; - const k = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; - class F { + const X = [48, 1632, 1776, 2406, 2534, 2662, 2790, 2918, 3046, 3174, 3302, 3430, 3558, 3664, 3792, 3872, 4160, 4240, 6112, 6160, 6470, 6608, 6784, 6800, 6992, 7088, 7232, 7248, 65296, 120782, 120792, 120802, 120812, 120822, 66720, 68912, 69734, 69872, 69942, 70096, 70384, 70736, 70864, 71248, 71360, 71472, 71904, 72016, 72688, 72784, 73040, 73120, 73552, 92768, 92864, 93008, 123200, 123632, 124144, 125264, 130032], W = /* @__PURE__ */ new Map(), z = 1632, Y = new Uint8Array(63904).fill(255); + for (const t2 of X) for (let e2 = 0; e2 < 10; e2++) { + const n2 = t2 + e2; + n2 <= 65535 ? Y[n2 - z] = e2 : W.set(n2, e2); + } + const H = /* @__PURE__ */ new Set([8722, 65293, 65123]), Q = /^[-+]?0x[a-fA-F0-9]+$/, J = /^0b[01]+$/, Z = /^0o[0-7]+$/, K = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/, tt = { hex: true, binary: false, octal: false, leadingZeros: true, decimalPoint: ".", eNotation: true, infinity: "original", unicode: false }; + function et(t2, e2 = {}) { + if (e2 = Object.assign({}, tt, e2), !t2 || "string" != typeof t2) return t2; + let n2 = t2.trim(); + if (0 === n2.length) return t2; + if (void 0 !== e2.skipLike && e2.skipLike.test(n2)) return t2; + if ("0" === n2) return 0; + if (e2.unicode && (n2 = (function(t3) { + if ("string" != typeof t3) return t3; + const e3 = t3.length; + if (0 === e3) return t3; + let n3 = -1; + for (let i3 = 0; i3 < e3; i3++) { + const r2 = t3.charCodeAt(i3); + if (!(r2 >= 48 && r2 <= 57 || 45 === r2)) { + if (r2 < z) { + if (H.has(r2)) { + n3 = i3; + break; + } + } else if (r2 >= 55296 && r2 <= 56319) { + if (i3 + 1 < e3) { + const e4 = t3.charCodeAt(i3 + 1); + if (e4 >= 56320 && e4 <= 57343) { + const t4 = 65536 + (r2 - 55296 << 10) + (e4 - 56320); + if (W.has(t4)) { + n3 = i3; + break; + } + } + } + } else if (255 !== Y[r2 - z] || H.has(r2)) { + n3 = i3; + break; + } + } + } + if (-1 === n3) return t3; + const i2 = []; + n3 > 0 && i2.push(t3.slice(0, n3)); + for (let r2 = n3; r2 < e3; r2++) { + const n4 = t3.charCodeAt(r2); + if (n4 >= 48 && n4 <= 57 || 45 === n4) { + i2.push(t3[r2]); + continue; + } + if (n4 < z) { + i2.push(H.has(n4) ? "-" : t3[r2]); + continue; + } + if (n4 >= 55296 && n4 <= 56319) { + if (r2 + 1 < e3) { + const e4 = t3.charCodeAt(r2 + 1); + if (e4 >= 56320 && e4 <= 57343) { + const t4 = 65536 + (n4 - 55296 << 10) + (e4 - 56320), s3 = W.get(t4); + if (void 0 !== s3) { + i2.push(String.fromCharCode(s3 + 48)), r2++; + continue; + } + } + } + i2.push(t3[r2]); + continue; + } + if (H.has(n4)) { + i2.push("-"); + continue; + } + const s2 = Y[n4 - z]; + i2.push(255 !== s2 ? String.fromCharCode(s2 + 48) : t3[r2]); + } + return i2.join(""); + })(n2), "0" === n2)) return 0; + if (e2.hex && Q.test(n2)) return it(n2, 16); + if (e2.binary && J.test(n2)) return it(n2, 2); + if (e2.octal && Z.test(n2)) return it(n2, 8); + if (isFinite(n2)) { + if (n2.includes("e") || n2.includes("E")) return (function(t3, e3, n3) { + if (!n3.eNotation) return t3; + const i2 = e3.match(nt); + if (i2) { + let r2 = i2[1] || ""; + const s2 = -1 === i2[3].indexOf("e") ? "E" : "e", o2 = i2[2], a2 = r2 ? e3[o2.length + 1] === s2 : e3[o2.length] === s2; + return o2.length > 1 && a2 ? t3 : (1 !== o2.length || !i2[3].startsWith(`.${s2}`) && i2[3][0] !== s2) && o2.length > 0 ? n3.leadingZeros && !a2 ? Number(e3) : t3 : Number(e3); + } + return t3; + })(t2, n2, e2); + { + const i2 = K.exec(n2); + if (i2) { + const r2 = i2[1] || "", s2 = i2[2]; + let o2 = (function(t3) { + if (t3 && -1 !== t3.indexOf(".")) { + let e3 = t3.length; + for (; e3 > 0 && 48 === t3.charCodeAt(e3 - 1); ) e3--; + return "." === (t3 = t3.slice(0, e3)) ? t3 = "0" : "." === t3[0] ? t3 = "0" + t3 : "." === t3[t3.length - 1] && (t3 = t3.substring(0, t3.length - 1)), t3; + } + return t3; + })(i2[3]); + const a2 = r2 ? "." === n2[s2.length + 1] : "." === n2[s2.length]; + if (!e2.leadingZeros && (s2.length > 1 || 1 === s2.length && !a2)) return t2; + { + const i3 = Number(n2), a3 = String(i3); + if (0 === i3) return i3; + if (-1 !== a3.search(/[eE]/)) return e2.eNotation ? i3 : t2; + if (-1 !== n2.indexOf(".")) return "0" === a3 || a3 === o2 || a3 === `${r2}${o2}` ? i3 : t2; + let l2 = s2 ? o2 : n2; + return s2 ? l2 === a3 || r2 + l2 === a3 ? i3 : t2 : l2 === a3 || l2 === r2 + a3 ? i3 : t2; + } + } + return t2; + } + } + { + const i2 = Number(n2); + return Number.isNaN(i2) ? t2 : (function(t3, e3, n3) { + const i3 = e3 === 1 / 0; + switch (n3.infinity.toLowerCase()) { + case "null": + return null; + case "infinity": + return e3; + case "string": + return i3 ? "Infinity" : "-Infinity"; + default: + return t3; + } + })(t2, i2, e2); + } + } + const nt = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/; + function it(t2, e2) { + const n2 = t2.trim(); + if (2 !== e2 && 8 !== e2 || (t2 = n2.substring(2)), parseInt) return parseInt(t2, e2); + if (Number.parseInt) return Number.parseInt(t2, e2); + if (window && window.parseInt) return window.parseInt(t2, e2); + throw new Error("parseInt, Number.parseInt, window.parseInt are not supported"); + } + class rt { constructor(t2) { this._matcher = t2; } @@ -54973,6 +55375,12 @@ var require_fxp = __commonJS({ const n2 = e2[e2.length - 1]; return void 0 !== n2.values && t2 in n2.values; } + getAnyParentAttr(t2) { + return this._matcher.getAnyParentAttr(t2); + } + hasAnyParentAttr(t2) { + return this._matcher.hasAnyParentAttr(t2); + } getPosition() { const t2 = this._matcher.path; return 0 === t2.length ? -1 : t2[t2.length - 1].position ?? 0; @@ -55000,26 +55408,33 @@ var require_fxp = __commonJS({ return t2.matchesAny(this._matcher); } } - class R { + class st { constructor(t2 = {}) { - this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new F(this); + this.separator = t2.separator || ".", this.path = [], this.siblingStacks = [], this._pathStringCache = null, this._view = new rt(this), this._keptAttrs = []; } - push(t2, e2 = null, n2 = null) { + push(t2, e2 = null, n2 = null, i2 = null) { this._pathStringCache = null, this.path.length > 0 && (this.path[this.path.length - 1].values = void 0); - const i2 = this.path.length; - this.siblingStacks[i2] || (this.siblingStacks[i2] = /* @__PURE__ */ new Map()); - const s2 = this.siblingStacks[i2], r2 = n2 ? `${n2}:${t2}` : t2, o2 = s2.get(r2) || 0; - let a2 = 0; - for (const t3 of s2.values()) a2 += t3; - s2.set(r2, o2 + 1); - const h2 = { tag: t2, position: a2, counter: o2 }; - null != n2 && (h2.namespace = n2), null != e2 && (h2.values = e2), this.path.push(h2); + const r2 = this.path.length; + let s2 = this.siblingStacks[r2]; + s2 || (s2 = { counts: /* @__PURE__ */ new Map(), total: 0 }, this.siblingStacks[r2] = s2); + const o2 = n2 ? `${n2}:${t2}` : t2, a2 = s2.counts.get(o2) || 0, l2 = s2.total; + s2.counts.set(o2, a2 + 1), s2.total++; + const c2 = { tag: t2, position: l2, counter: a2 }; + null != n2 && (c2.namespace = n2), null != e2 && (c2.values = e2), this.path.push(c2); + const p2 = this.path.length, h2 = null !== i2 ? i2.keep : null; + if (null != h2 && h2.length > 0 && e2) for (let t3 = 0; t3 < h2.length; t3++) { + const n3 = h2[t3]; + void 0 !== e2[n3] && this._keptAttrs.push({ depth: p2, name: n3, value: e2[n3] }); + } } pop() { if (0 === this.path.length) return; this._pathStringCache = null; const t2 = this.path.pop(); - return this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1), t2; + this.siblingStacks.length > this.path.length + 1 && (this.siblingStacks.length = this.path.length + 1); + const e2 = this.path.length + 1; + for (; this._keptAttrs.length > 0 && this._keptAttrs[this._keptAttrs.length - 1].depth >= e2; ) this._keptAttrs.pop(); + return t2; } updateCurrent(t2) { if (this.path.length > 0) { @@ -55041,6 +55456,15 @@ var require_fxp = __commonJS({ const e2 = this.path[this.path.length - 1]; return void 0 !== e2.values && t2 in e2.values; } + getAnyParentAttr(t2) { + const e2 = this._keptAttrs; + for (let n2 = e2.length - 1; n2 >= 0; n2--) if (e2[n2].name === t2) return e2[n2].value; + } + hasAnyParentAttr(t2) { + const e2 = this._keptAttrs; + for (let n2 = e2.length - 1; n2 >= 0; n2--) if (e2[n2].name === t2) return true; + return false; + } getPosition() { return 0 === this.path.length ? -1 : this.path[this.path.length - 1].position ?? 0; } @@ -55066,7 +55490,7 @@ var require_fxp = __commonJS({ return this.path.map((t2) => t2.tag); } reset() { - this._pathStringCache = null, this.path = [], this.siblingStacks = []; + this._pathStringCache = null, this.path = [], this.siblingStacks = [], this._keptAttrs = []; } matches(t2) { const e2 = t2.segments; @@ -55084,12 +55508,12 @@ var require_fxp = __commonJS({ if ("deep-wildcard" === i2.type) { if (n2--, n2 < 0) return true; const i3 = t2[n2]; - let s2 = false; + let r2 = false; for (let t3 = e2; t3 >= 0; t3--) if (this._matchSegment(i3, this.path[t3], t3 === this.path.length - 1)) { - e2 = t3 - 1, n2--, s2 = true; + e2 = t3 - 1, n2--, r2 = true; break; } - if (!s2) return false; + if (!r2) return false; } else { if (!this._matchSegment(i2, this.path[e2], e2 === this.path.length - 1)) return false; e2--, n2--; @@ -55119,16 +55543,16 @@ var require_fxp = __commonJS({ return t2.matchesAny(this); } snapshot() { - return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => new Map(t2)) }; + return { path: this.path.map((t2) => ({ ...t2 })), siblingStacks: this.siblingStacks.map((t2) => t2 ? { counts: new Map(t2.counts), total: t2.total } : t2), keptAttrs: this._keptAttrs.map((t2) => ({ ...t2 })) }; } restore(t2) { - this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => new Map(t3)); + this._pathStringCache = null, this.path = t2.path.map((t3) => ({ ...t3 })), this.siblingStacks = t2.siblingStacks.map((t3) => t3 ? { counts: new Map(t3.counts), total: t3.total } : t3), this._keptAttrs = (t2.keptAttrs || []).map((t3) => ({ ...t3 })); } readOnly() { return this._view; } } - class G { + class ot { constructor(t2, e2 = {}, n2) { this.pattern = t2, this.separator = e2.separator || ".", this.segments = this._parse(t2), this.data = n2, this._hasDeepWildcard = this.segments.some((t3) => "deep-wildcard" === t3.type), this._hasAttributeCondition = this.segments.some((t3) => void 0 !== t3.attrName), this._hasPositionSelector = this.segments.some((t3) => void 0 !== t3.position); } @@ -55141,29 +55565,29 @@ var require_fxp = __commonJS({ _parseSegment(t2) { const e2 = { type: "tag" }; let n2 = null, i2 = t2; - const s2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); - if (s2 && (i2 = s2[1] + s2[3], s2[2])) { - const t3 = s2[2].slice(1, -1); + const r2 = t2.match(/^([^\[]+)(\[[^\]]*\])(.*)$/); + if (r2 && (i2 = r2[1] + r2[3], r2[2])) { + const t3 = r2[2].slice(1, -1); t3 && (n2 = t3); } - let r2, o2, a2 = i2; + let s2, o2, a2 = i2; if (i2.includes("::")) { const e3 = i2.indexOf("::"); - if (r2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !r2) throw new Error(`Invalid namespace in pattern: ${t2}`); + if (s2 = i2.substring(0, e3).trim(), a2 = i2.substring(e3 + 2).trim(), !s2) throw new Error(`Invalid namespace in pattern: ${t2}`); } - let h2 = null; + let l2 = null; if (a2.includes(":")) { const t3 = a2.lastIndexOf(":"), e3 = a2.substring(0, t3).trim(), n3 = a2.substring(t3 + 1).trim(); - ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, h2 = n3) : o2 = a2; + ["first", "last", "odd", "even"].includes(n3) || /^nth\(\d+\)$/.test(n3) ? (o2 = e3, l2 = n3) : o2 = a2; } else o2 = a2; if (!o2) throw new Error(`Invalid segment pattern: ${t2}`); - if (e2.tag = o2, r2 && (e2.namespace = r2), n2) if (n2.includes("=")) { + if (e2.tag = o2, s2 && (e2.namespace = s2), n2) if (n2.includes("=")) { const t3 = n2.indexOf("="); e2.attrName = n2.substring(0, t3).trim(), e2.attrValue = n2.substring(t3 + 1).trim(); } else e2.attrName = n2.trim(); - if (h2) { - const t3 = h2.match(/^nth\((\d+)\)$/); - t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = h2; + if (l2) { + const t3 = l2.match(/^nth\((\d+)\)$/); + t3 ? (e2.position = "nth", e2.positionValue = parseInt(t3[1], 10)) : e2.position = l2; } return e2; } @@ -55183,14 +55607,21 @@ var require_fxp = __commonJS({ return this.pattern; } } - class B { + class at { constructor() { - this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; + this._byDepthAndTag = /* @__PURE__ */ new Map(), this._wildcardByDepth = /* @__PURE__ */ new Map(), this._deepWildcards = [], this._deepByTerminalTag = /* @__PURE__ */ new Map(), this._patterns = /* @__PURE__ */ new Set(), this._sealed = false; } add(t2) { if (this._sealed) throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."); if (this._patterns.has(t2.pattern)) return this; - if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) return this._deepWildcards.push(t2), this; + if (this._patterns.add(t2.pattern), t2.hasDeepWildcard()) { + const e3 = t2.segments[t2.segments.length - 1]; + if (e3 && "deep-wildcard" !== e3.type && "*" !== e3.tag) { + const n3 = e3.tag; + this._deepByTerminalTag.has(n3) || this._deepByTerminalTag.set(n3, []), this._deepByTerminalTag.get(n3).push(t2); + } else this._deepWildcards.push(t2); + return this; + } const e2 = t2.length, n2 = t2.segments[t2.segments.length - 1], i2 = n2?.tag; if (i2 && "*" !== i2) { const n3 = `${e2}:${i2}`; @@ -55218,25 +55649,29 @@ var require_fxp = __commonJS({ return null !== this.findMatch(t2); } findMatch(t2) { - const e2 = t2.getDepth(), n2 = `${e2}:${t2.getCurrentTag()}`, i2 = this._byDepthAndTag.get(n2); - if (i2) { - for (let e3 = 0; e3 < i2.length; e3++) if (t2.matches(i2[e3])) return i2[e3]; + const e2 = t2.getDepth(), n2 = t2.getCurrentTag(), i2 = `${e2}:${n2}`, r2 = this._byDepthAndTag.get(i2); + if (r2) { + for (let e3 = 0; e3 < r2.length; e3++) if (t2.matches(r2[e3])) return r2[e3]; } const s2 = this._wildcardByDepth.get(e2); if (s2) { for (let e3 = 0; e3 < s2.length; e3++) if (t2.matches(s2[e3])) return s2[e3]; } + const o2 = this._deepByTerminalTag.get(n2); + if (o2) { + for (let e3 = 0; e3 < o2.length; e3++) if (t2.matches(o2[e3])) return o2[e3]; + } for (let e3 = 0; e3 < this._deepWildcards.length; e3++) if (t2.matches(this._deepWildcards[e3])) return this._deepWildcards[e3]; return null; } } - const U = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", euro: "\u20AC", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, W = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, X = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, Y = new Set("!?\\\\/[]$%{}^&*()<>|+"); - function z(t2) { + const lt2 = { cent: "\xA2", pound: "\xA3", curren: "\xA4", yen: "\xA5", euro: "\u20AC", dollar: "$", fnof: "\u0192", inr: "\u20B9", af: "\u060B", birr: "\u1265\u122D", peso: "\u20B1", rub: "\u20BD", won: "\u20A9", yuan: "\xA5", cedil: "\xB8" }, ct = { amp: "&", apos: "'", gt: ">", lt: "<", quot: '"' }, pt = { nbsp: "\xA0", copy: "\xA9", reg: "\xAE", trade: "\u2122", mdash: "\u2014", ndash: "\u2013", hellip: "\u2026", laquo: "\xAB", raquo: "\xBB", lsquo: "\u2018", rsquo: "\u2019", ldquo: "\u201C", rdquo: "\u201D", bull: "\u2022", para: "\xB6", sect: "\xA7", deg: "\xB0", frac12: "\xBD", frac14: "\xBC", frac34: "\xBE" }, ht = Object.freeze({ ALLOW: "allow", BLOCK: "block", THROW: "throw" }), dt = new Set("!?\\\\/[]$%{}^&*()<>|+"); + function ut(t2) { if ("#" === t2[0]) throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${t2}"`); - for (const e2 of t2) if (Y.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); + for (const e2 of t2) if (dt.has(e2)) throw new Error(`[EntityReplacer] Invalid character '${e2}' in entity name: "${t2}"`); return t2; } - function q(...t2) { + function ft(...t2) { const e2 = /* @__PURE__ */ Object.create(null); for (const n2 of t2) if (n2) for (const t3 of Object.keys(n2)) { const i2 = n2[t3]; @@ -55248,27 +55683,40 @@ var require_fxp = __commonJS({ } return e2; } - const Z = "external", J = "base", K = "all", Q = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), H = /* @__PURE__ */ new Set([9, 10, 13]); - class tt { + const gt = "external", mt = "base", xt = "all", bt = Object.freeze({ allow: 0, leave: 1, remove: 2, throw: 3 }), yt = /* @__PURE__ */ new Set([9, 10, 13]); + class Nt { constructor(t2 = {}) { var e2; - this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? Z) && e2 !== Z ? e2 === K ? /* @__PURE__ */ new Set([K]) : e2 === J ? /* @__PURE__ */ new Set([J]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([Z]) : /* @__PURE__ */ new Set([Z]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = q(W, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); + this._limit = t2.limit || {}, this._maxTotalExpansions = this._limit.maxTotalExpansions || 0, this._maxExpandedLength = this._limit.maxExpandedLength || 0, this._postCheck = "function" == typeof t2.postCheck ? t2.postCheck : (t3) => t3, this._limitTiers = (e2 = this._limit.applyLimitsTo ?? gt) && e2 !== gt ? e2 === xt ? /* @__PURE__ */ new Set([xt]) : e2 === mt ? /* @__PURE__ */ new Set([mt]) : Array.isArray(e2) ? new Set(e2) : /* @__PURE__ */ new Set([gt]) : /* @__PURE__ */ new Set([gt]), this._numericAllowed = t2.numericAllowed ?? true, this._baseMap = ft(ct, t2.namedEntities || null), this._externalMap = /* @__PURE__ */ Object.create(null), this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this._removeSet = new Set(t2.remove && Array.isArray(t2.remove) ? t2.remove : []), this._leaveSet = new Set(t2.leave && Array.isArray(t2.leave) ? t2.leave : []); const n2 = (function(t3) { - if (!t3) return { xmlVersion: 1, onLevel: Q.allow, nullLevel: Q.remove }; - const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = Q[t3.onNCR] ?? Q.allow, i2 = Q[t3.nullNCR] ?? Q.remove; - return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, Q.remove) }; + if (!t3) return { xmlVersion: 1, onLevel: bt.allow, nullLevel: bt.remove }; + const e3 = 1.1 === t3.xmlVersion ? 1.1 : 1, n3 = bt[t3.onNCR] ?? bt.allow, i2 = bt[t3.nullNCR] ?? bt.remove; + return { xmlVersion: e3, onLevel: n3, nullLevel: Math.max(i2, bt.remove) }; })(t2.ncr); - this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel; + this._ncrXmlVersion = n2.xmlVersion, this._ncrOnLevel = n2.onLevel, this._ncrNullLevel = n2.nullLevel, this._onExternalEntity = "function" == typeof t2.onExternalEntity ? t2.onExternalEntity : null, this._onInputEntity = "function" == typeof t2.onInputEntity ? t2.onInputEntity : null; + } + _applyRegistrationHook(t2, e2, n2, i2) { + if (!t2) return true; + const r2 = t2(e2, n2); + if (r2 === ht.BLOCK) return false; + if (r2 === ht.THROW) throw new Error(`[EntityDecoder] Registration of ${i2} entity "&${e2};" was rejected by hook`); + return true; } setExternalEntities(t2) { - if (t2) for (const e2 of Object.keys(t2)) z(e2); - this._externalMap = q(t2); + if (t2) for (const e3 of Object.keys(t2)) ut(e3); + if (!this._onExternalEntity) return void (this._externalMap = ft(t2)); + const e2 = ft(t2), n2 = /* @__PURE__ */ Object.create(null); + for (const [t3, i2] of Object.entries(e2)) this._applyRegistrationHook(this._onExternalEntity, t3, i2, "external") && (n2[t3] = i2); + this._externalMap = n2; } addExternalEntity(t2, e2) { - z(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && (this._externalMap[t2] = e2); + ut(t2), "string" == typeof e2 && -1 === e2.indexOf("&") && this._applyRegistrationHook(this._onExternalEntity, t2, e2, "external") && (this._externalMap[t2] = e2); } addInputEntities(t2) { - this._totalExpansions = 0, this._expandedLength = 0, this._inputMap = q(t2); + if (this._totalExpansions = 0, this._expandedLength = 0, !this._onInputEntity) return void (this._inputMap = ft(t2)); + const e2 = ft(t2), n2 = /* @__PURE__ */ Object.create(null); + for (const [t3, i2] of Object.entries(e2)) this._applyRegistrationHook(this._onInputEntity, t3, i2, "input") && (n2[t3] = i2); + this._inputMap = n2; } reset() { return this._inputMap = /* @__PURE__ */ Object.create(null), this._totalExpansions = 0, this._expandedLength = 0, this; @@ -55278,76 +55726,77 @@ var require_fxp = __commonJS({ } decode(t2) { if ("string" != typeof t2 || 0 === t2.length) return t2; + if (-1 === t2.indexOf("&")) return t2; const e2 = t2, n2 = [], i2 = t2.length; - let s2 = 0, r2 = 0; - const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, h2 = o2 || a2; - for (; r2 < i2; ) { - if (38 !== t2.charCodeAt(r2)) { - r2++; + let r2 = 0, s2 = 0; + const o2 = this._maxTotalExpansions > 0, a2 = this._maxExpandedLength > 0, l2 = o2 || a2; + for (; s2 < i2; ) { + if (38 !== t2.charCodeAt(s2)) { + s2++; continue; } - let e3 = r2 + 1; - for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - r2 <= 32; ) e3++; + let e3 = s2 + 1; + for (; e3 < i2 && 59 !== t2.charCodeAt(e3) && e3 - s2 <= 32; ) e3++; if (e3 >= i2 || 59 !== t2.charCodeAt(e3)) { - r2++; + s2++; continue; } - const l3 = t2.slice(r2 + 1, e3); - if (0 === l3.length) { - r2++; + const c3 = t2.slice(s2 + 1, e3); + if (0 === c3.length) { + s2++; continue; } - let u2, p2; - if (this._removeSet.has(l3)) u2 = "", void 0 === p2 && (p2 = Z); + let p2, h2; + if (this._removeSet.has(c3)) p2 = "", void 0 === h2 && (h2 = gt); else { - if (this._leaveSet.has(l3)) { - r2++; + if (this._leaveSet.has(c3)) { + s2++; continue; } - if (35 === l3.charCodeAt(0)) { - const t3 = this._resolveNCR(l3); + if (35 === c3.charCodeAt(0)) { + const t3 = this._resolveNCR(c3); if (void 0 === t3) { - r2++; + s2++; continue; } - u2 = t3, p2 = J; + p2 = t3, h2 = mt; } else { - const t3 = this._resolveName(l3); - u2 = t3?.value, p2 = t3?.tier; + const t3 = this._resolveName(c3); + p2 = t3?.value, h2 = t3?.tier; } } - if (void 0 !== u2) { - if (r2 > s2 && n2.push(t2.slice(s2, r2)), n2.push(u2), s2 = e3 + 1, r2 = s2, h2 && this._tierCounts(p2)) { + if (void 0 !== p2) { + if (s2 > r2 && n2.push(t2.slice(r2, s2)), n2.push(p2), r2 = e3 + 1, s2 = r2, l2 && this._tierCounts(h2)) { if (o2 && (this._totalExpansions++, this._totalExpansions > this._maxTotalExpansions)) throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`); if (a2) { - const t3 = u2.length - (l3.length + 2); + const t3 = p2.length - (c3.length + 2); if (t3 > 0 && (this._expandedLength += t3, this._expandedLength > this._maxExpandedLength)) throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`); } } - } else r2++; + } else s2++; } - s2 < i2 && n2.push(t2.slice(s2)); - const l2 = 0 === n2.length ? t2 : n2.join(""); - return this._postCheck(l2, e2); + r2 < i2 && n2.push(t2.slice(r2)); + const c2 = 0 === n2.length ? t2 : n2.join(""); + return this._postCheck(c2, e2); } _tierCounts(t2) { - return !!this._limitTiers.has(K) || this._limitTiers.has(t2); + return !!this._limitTiers.has(xt) || this._limitTiers.has(t2); } _resolveName(t2) { - return t2 in this._inputMap ? { value: this._inputMap[t2], tier: Z } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: Z } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: J } : void 0; + return t2 in this._inputMap ? { value: this._inputMap[t2], tier: gt } : t2 in this._externalMap ? { value: this._externalMap[t2], tier: gt } : t2 in this._baseMap ? { value: this._baseMap[t2], tier: mt } : void 0; } _classifyNCR(t2) { - return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !H.has(t2) ? Q.remove : -1; + return 0 === t2 ? this._ncrNullLevel : t2 >= 55296 && t2 <= 57343 || 1 === this._ncrXmlVersion && t2 >= 1 && t2 <= 31 && !yt.has(t2) ? bt.remove : -1; } _applyNCRAction(t2, e2, n2) { switch (t2) { - case Q.allow: + case bt.allow: return String.fromCodePoint(n2); - case Q.remove: + case bt.remove: return ""; - case Q.leave: + case bt.leave: return; - case Q.throw: + case bt.throw: throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e2}; (U+${n2.toString(16).toUpperCase().padStart(4, "0")})`); default: return String.fromCodePoint(n2); @@ -55358,12 +55807,46 @@ var require_fxp = __commonJS({ let n2; if (n2 = 120 === e2 || 88 === e2 ? parseInt(t2.slice(2), 16) : parseInt(t2.slice(1), 10), Number.isNaN(n2) || n2 < 0 || n2 > 1114111) return; const i2 = this._classifyNCR(n2); - if (!this._numericAllowed && i2 < Q.remove) return; - const s2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); - return this._applyNCRAction(s2, t2, n2); + if (!this._numericAllowed && i2 < bt.remove) return; + const r2 = -1 === i2 ? this._ncrOnLevel : Math.max(this._ncrOnLevel, i2); + return this._applyNCRAction(r2, t2, n2); } } - function et(t2, e2) { + const Et = [{ id: "sql-block-comment-open", description: "SQL block comment open: /* ... */ \u2014 unusual in legitimate user text", pattern: /\/\*/ }, { id: "sql-union-select", description: "UNION SELECT \u2014 most common SQL injection aggregation attack", pattern: /\bUNION\s{1,20}(?:ALL\s{1,20})?SELECT\b/i }, { id: "sql-drop-table", description: "DROP TABLE \u2014 destructive DDL injection", pattern: /\bDROP\s{1,20}TABLE\b/i }, { id: "sql-drop-database", description: "DROP DATABASE \u2014 destructive DDL injection", pattern: /\bDROP\s{1,20}DATABASE\b/i }, { id: "sql-insert-into", description: "INSERT INTO \u2014 data injection", pattern: /\bINSERT\s{1,20}INTO\b/i }, { id: "sql-delete-from", description: "DELETE FROM \u2014 data deletion injection", pattern: /\bDELETE\s{1,20}FROM\b/i }, { id: "sql-update-set", description: "UPDATE ... SET \u2014 data modification injection", pattern: /\bUPDATE\b[\s\S]{1,60}\bSET\b/i }, { id: "sql-exec-xp", description: "EXEC xp_ \u2014 MSSQL extended stored procedure execution", pattern: /\bEXEC(?:UTE)?\s{1,20}xp_/i }, { id: "sql-tautology-string", description: `Classic string tautology: ' OR '1'='1 or " OR "1"="1"`, pattern: /'\s{0,10}OR\s{0,10}'[^']{0,20}'\s*=\s*'[^']{0,20}/i }, { id: "sql-tautology-numeric", description: "Numeric tautology: OR 1=1", pattern: /\bOR\s{1,10}1\s*=\s*1\b/i }, { id: "sql-always-true-zero", description: "Numeric tautology: OR 0=0", pattern: /\bOR\s{1,10}0\s*=\s*0\b/i }, { id: "sql-sleep-benchmark", description: "Time-based blind injection: SLEEP() or BENCHMARK()", pattern: /\b(?:SLEEP|BENCHMARK)\s*\(/i }, { id: "sql-waitfor-delay", description: "MSSQL time-based blind injection: WAITFOR DELAY", pattern: /\bWAITFOR\s{1,20}DELAY\b/i }, { id: "sql-char-function", description: "CHAR() function \u2014 used to obfuscate injected strings", pattern: /\bCHAR\s*\(\s*\d{1,3}/i }, { id: "sql-information-schema", description: "INFORMATION_SCHEMA \u2014 reconnaissance query for table/column enumeration", pattern: /\bINFORMATION_SCHEMA\b/i }], wt = [...Et, { id: "sql-line-comment", description: "SQL line comment: -- followed by whitespace or end of string", pattern: /--(?:\s|$)/ }, { id: "sql-stacked-query", description: "Stacked queries: semicolon immediately followed by a SQL keyword", pattern: /;\s{0,10}(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER|EXEC)\b/i }, { id: "sql-hex-encoding", description: "Hex-encoded string injection: 0x41414141 style (MySQL)", pattern: /\b0x[0-9a-f]{4,}/i }], vt = Object.freeze({ colon: ":", Tab: " ", NewLine: "\n" }), St = /&(?:#[xX]0*([0-9a-fA-F]{1,6});?|#0*([0-9]{1,7});?|([a-zA-Z][a-zA-Z0-9]{1,15});)/g, At = [{ id: "html-script-open", description: "]/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 \u2014 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 \u2014 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