Repository navigation
feat: refuse a src no package can be fetched from - #10
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
<h5p-player>now refuses asrcwhose scheme no package can be fetched from, before making any request.Allowed:
http:,https:,blob:anddata:, plus relative URLs, which resolve against the page.http:on anhttps:page still gets the existing mixed-content message that suggests thehttps:URL.Refused: anything else, such as
javascript:,file:,ftp:or a typo. The probe now throwsPlayerError('network', 'javascript: URLs cannot be played. Use an http:, https:, blob: or data: URL.'), so the element goes toerrorwith a message that names the scheme. Before, the value reachedfetch, which rejects it with aTypeErrorthat 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 reachfetch, and the allowed ones, relative URLs included, pass. The player's full unit and browser suites pass (361 tests).🤖 Generated with Claude Code