Skip to content

Decode data: URIs in fetchData instead of fetching them - #1773

Merged
obiot merged 2 commits into
masterfrom
claude/lucid-ptolemy-2c6hx4
Oct 27, 2026
Merged

obiot merged 2 commits into
masterfrom
claude/lucid-ptolemy-2c6hx4

Conversation

@obiot

@obiot obiot commented Oct 27, 2026

Copy link
Copy Markdown
Member

Description

The default loading screen's logo is inlined by the build as a data:image/png;base64,... URI, and every image went through fetchData → fetch(). fetch() of a data: URL is checked against the CSP connect-src directive, so on pages that restrict it (sandboxed embeds, claude.ai artifacts, hardened sites) the browser refused it and the logo never showed.

fetchData now decodes data: URIs locally (base64 or percent-encoded, keeping the media type and its parameters) and returns the same Response-shaped object the file: XHR path uses, so the code that handles the response is unchanged. The data: check runs before the file: check, because on a file: page every URL would otherwise go to XHR. Since it sits in fetchData, it covers a data: URI given to any asset type (image, json, binary, glTF, audio…), not only the logo. Other URLs are untouched.

Verified with the built engine on a page served with connect-src 'self':

  • before: a connect-src violation for data: and an empty loading screen
  • after: no violation, and the logo renders

Type of change

  • Bug fix

Checklist

  • My code follows the existing code style (biome + eslint pass on the changed files)
  • I have tested my changes locally: the new spec plus the fetchData, loader and glTF specs pass. In the full run, 2–4 rendering/benchmark specs (drawmesh_bench, text-ink-clipping, plus intermittently bitmaptext-glyph-effect, particle-tint-over-life) failed in my sandbox, and they fail the same way without this change
  • I have added tests that cover my changes: tests/data-uri-load.spec.js loads a data-URI PNG through the image parser and asserts fetch is never called; it also covers blob/arrayBuffer/text/json decoding and malformed URIs
  • The build succeeds

Related issues

None


Generated by Claude Code

fetch() of a data: URL is checked against the CSP connect-src directive,
so on pages that restrict it (sandboxed embeds, hardened sites) the
browser refused the loading screen's inlined logo. fetchData now decodes
data: URIs locally (base64 or percent-encoded) and returns the same
Response-shaped object as the file: XHR path, so every parser gets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA2LgdsfmEdYD4czqim
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

A non-base64 payload went through decodeURIComponent, which throws on a
percent-encoded byte that is not part of valid UTF-8 (a lone %FF), so a
binary data: URI that fetch() loads failed to load. It is now
percent-decoded to bytes: each %XX is that byte, anything else its UTF-8
bytes. A media type left out but followed by parameters is text/plain,
not ";charset=...".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SeWCkETjW35ZbXDRswV1hx
Copilot AI balanced review requested due to automatic review settings October 27, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@obiot
obiot merged commit 867f0b9 into master Oct 27, 2026
6 checks passed
@obiot
obiot deleted the claude/lucid-ptolemy-2c6hx4 branch October 27, 2026 08:44
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.

3 participants