Skip to content

Fix XSS vulnerability and improve error handling in manifest-import component#414

Merged
cubap merged 2 commits intoiiif-import-directfrom
copilot/sub-pr-406-again
Feb 2, 2026
Merged

Fix XSS vulnerability and improve error handling in manifest-import component#414
cubap merged 2 commits intoiiif-import-directfrom
copilot/sub-pr-406-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Addresses critical security vulnerability and code quality issues in the manifest-import component identified in static review.

Changes

  • Security: Escape error.message and error.manifestUrl before rendering to prevent XSS attacks from malicious query parameters or API responses
  • Error handling: Wrap JSON parsing in try/catch to handle non-JSON error responses (HTML error pages, gateway errors)
  • Code cleanup: Remove unused getUserFromToken import
  • Lifecycle: Add disconnectedCallback() for proper component cleanup

Example

Before:

${failed.map(error => `
    <div class="error-item">
        <strong>${error.message}</strong>
        <div class="error-url">${error.manifestUrl}</div>
    </div>
`).join('')}

After:

${failed.map(error => `
    <div class="error-item">
        <strong>${escapeHtml(error.message || '')}</strong>
        <div class="error-url">${escapeHtml(error.manifestUrl || '')}</div>
    </div>
`).join('')}

CodeQL: 0 alerts


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Copilot AI changed the title [WIP] Add IIIF import interface for direct project creation Fix XSS vulnerability and improve error handling in manifest-import component Feb 2, 2026
Copilot AI requested a review from cubap February 2, 2026 15:15
@cubap cubap marked this pull request as ready for review February 2, 2026 15:36
@cubap cubap merged commit bad65f4 into iiif-import-direct Feb 2, 2026
@cubap cubap deleted the copilot/sub-pr-406-again branch February 2, 2026 15:37
cubap added a commit that referenced this pull request Feb 2, 2026
* Add manifest import component and interface

Introduce a new Manifest Import feature: adds a web component (components/manifest-import/index.js) that imports multiple IIIF manifests into TPEN, handles authentication, creates projects sequentially, and renders progress/results. Includes docs and support pages (IMPLEMENTATION.md, README.md, QUICKSTART.md), an examples page and interface (interfaces/manifest-import/index.html, examples.html, INDEX.md), and interface metadata (manifest.yml). Uses TPEN Services POST /project/import?createFrom=URL and integrates with TPEN auth/token handling.

* Update index.js

* Update components/manifest-import/index.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update components/manifest-import/index.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update components/manifest-import/index.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* [WIP] Update to address feedback on IIIF import PR (#407)

* Initial plan

* Fix URL format in INDEX.md to match permalink

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

* Fix URL examples to use correct /import-manifest permalink (#408)

* Initial plan

* Fix URL examples to use /import-manifest path

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

* [WIP] Address feedback on IIIF import direct pull request (#409)

* Initial plan

* Replace custom #escapeHtml with shared utility from /js/utils.js

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

* [WIP] Address feedback from review on IIIF import (#410)

* Initial plan

* Fix /?manifest= to /import-manifest?manifest= across all documentation

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

* [WIP] WIP Address feedback on IIIF import direct pull request (#411)

* Initial plan

* Add main element wrapper for improved accessibility

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

* Fix XSS vulnerability and improve error handling in manifest-import component (#414)

* Initial plan

* Fix security and code quality issues in manifest-import component

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>

* last touches on pr

Add component lifecycle and concurrency improvements for manifest import: introduce a CleanupRegistry to manage event handlers and call cleanup.run() on disconnect; attach TPEN authentication and wait for tpen-authenticated events, render a need-auth state when not authorized, and guard initialization with a #hasInitialized flag to avoid double-init. Rework #createProjects to perform imports with a worker pool and a concurrency limit (5) while preserving result order and collecting per-manifest errors. Also enhance loader markup with ARIA attributes for better accessibility.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments