Skip to content

Fix thumbnail data URL MIME type detection - #507

Open
remcoder wants to merge 1 commit into
developfrom
codex/fix-thumbnail-mime-504
Open

remcoder wants to merge 1 commit into
developfrom
codex/fix-thumbnail-mime-504

Conversation

@remcoder

Copy link
Copy Markdown
Member

Problem

PNG thumbnails such as those embedded in demo/gcodes/screw.gcode declare image/jpeg in their data URLs, giving consumers the wrong content type. Fixes #504.

Cause

Thumbnail.src hardcodes the JPEG prefix regardless of the embedded image format. Browsers can sniff the payload, masking the mismatch.

Fix

Decode only the leading base64 characters and identify PNG, JPEG, or QOI from their magic bytes. Keep the existing JPEG fallback for unknown or malformed data so accessing src remains tolerant of incomplete input.

Behavior changes

PNG and QOI payloads now declare image/png and image/qoi; JPEG retains image/jpeg. The payload and getter signature remain unchanged.

Checks

  • npm run test:coverage: 984 tests pass; 100% statement, branch, function, and line coverage.
  • npm run typeCheck
  • npm run lint
  • npm run build
  • Regression coverage for PNG parsing, JPEG, QOI, unknown, empty, short, and malformed payloads.
  • Labelled bug and parser.

Assisted by Codex - GPT-6

@remcoder remcoder added bug Something isn't working parser Related to G-code parsing labels Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 1082231):

https://gcode-preview--pr507-codex-fix-thumbnail-0ca2pu1o.web.app

(expires Tue, 03 Nov 2026 09:23:10 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 59bd114ae4847b32c2bba0b68620b9069a3e3531

@remcoder remcoder closed this Oct 4, 2026
@remcoder remcoder reopened this Oct 4, 2026
@remcoder remcoder closed this Oct 4, 2026
@remcoder remcoder reopened this Oct 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working parser Related to G-code parsing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Thumbnail.src hardcoded jpeg MIME type

2 participants