Skip to content

feat: refuse a src no package can be fetched from - #10

Merged
alekswebnet merged 1 commit into
mainfrom
feat/src-scheme-check
Oct 6, 2026
Merged

alekswebnet merged 1 commit into
mainfrom
feat/src-scheme-check

Conversation

@alekswebnet

Copy link
Copy Markdown
Contributor

<h5p-player> now refuses a src whose scheme no package can be fetched from, before making any request.

Allowed: http:, https:, blob: and data:, plus relative URLs, which resolve against the page. http: on an https: page still gets the existing mixed-content message that suggests the https: URL.

Refused: anything else, such as javascript:, file:, ftp: or a typo. The probe now throws PlayerError('network', 'javascript: URLs cannot be played. Use an http:, https:, blob: or data: URL.'), so the element goes to error with a message that names the scheme. Before, the value reached fetch, which rejects it with a TypeError that reads like a network failure.

This is the hardening discussed for code scanning alerts #1–7 and #10–14 (setAttribute('src', …) on the element). Those alerts are at the pages' call sites, and CodeQL may not count a check inside the element as a fix, so they may stay open after merge. If they do, they're false positives to dismiss.

Tested: two new cases in tests/unit/source-probe.test.ts. The refused schemes never reach fetch, and the allowed ones, relative URLs included, pass. The player's full unit and browser suites pass (361 tests).

🤖 Generated with Claude Code

A javascript:, file: or ftp: src used to reach fetch, which rejects it
with a TypeError that reads like a network failure. The probe now
refuses anything but http:, https:, blob: and data: before any request,
with a message that names the scheme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
h5p-offline-player Ready Ready Preview Oct 6, 2026 7:48pm UTC

@alekswebnet
alekswebnet merged commit 020e87f into main Oct 6, 2026
7 checks passed
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.

1 participant