Skip to content

fix(media): add image/bmp to the default media upload allowlist - #3066

Open
zaochih wants to merge 2 commits into
emdash-cms:mainfrom
zaochih:add-bmp-to-allowlist
Open

fix(media): add image/bmp to the default media upload allowlist#3066
zaochih wants to merge 2 commits into
emdash-cms:mainfrom
zaochih:add-bmp-to-allowlist

Conversation

@zaochih

@zaochih zaochih commented Sep 11, 2026

Copy link
Copy Markdown

What does this PR do?

BMP uploads fail with "File type not allowed" because image/bmp is missing from GLOBAL_UPLOAD_ALLOWLIST — the same shape of regression as the earlier missing-AVIF bug (#2683). BMP is a plain raster format with no active-content risk, so it needs no security tradeoff to allow, unlike SVG.

Also adds image/bmp to the two "safe to render inline" sets (SAFE_INLINE_TYPES in the media file route, SAFE_INLINE_IMAGE_TYPES in media/image-endpoint.ts) so an uploaded BMP renders in an instead of being forced to download — without this a BMP would upload but still be unusable as an image. Extends .bmp extension shorthand support and the admin upload dialog/allowed-types preset to match.

Closes #3063

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main. Not applicable.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/... Not applicable.
  • I have included screenshots below if this PR changes the UI Not applicable.

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Sonnet 5 in Claude Code

Screenshots / test output

Not applicable

BMP uploads fail with "File type not allowed" because image/bmp is
missing from GLOBAL_UPLOAD_ALLOWLIST — the same shape of regression as
the earlier missing-AVIF bug (emdash-cms#2683). BMP is a plain raster format with
no active-content risk, so it needs no security tradeoff to allow,
unlike SVG.

Also adds image/bmp to the two "safe to render inline" sets
(SAFE_INLINE_TYPES in the media file route, SAFE_INLINE_IMAGE_TYPES in
media/image-endpoint.ts) so an uploaded BMP renders in an <img> instead
of being forced to download — without this a BMP would upload but still
be unusable as an image. Extends .bmp extension shorthand support and
the admin upload dialog/allowed-types preset to match.

Closes emdash-cms#3063
Copilot AI lite review requested due to automatic review settings September 11, 2026 11:49
@changeset-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 222120f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
emdash Patch
@emdash-cms/admin Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/release-service Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@emdashbot emdashbot Bot 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.

This PR is a clean, narrowly scoped bug fix: it adds image/bmp to all the relevant allowlists and inline-render sets, mirroring the earlier AVIF-shaped fix. I traced the change through the REST upload route, signed-URL route, MCP media_upload handler, the file-serving route, and the image-endpoint fallback; all now accept or serve BMP consistently. The admin preset, upload dialog accept string, and both EXTENSION_TO_MIME maps are updated in sync. The docs and changeset accurately describe the user-facing effect. The added tests assert observable behavior (allowlist match, Content-Disposition: inline, extension shorthand) rather than pinning constants. No AGENTS.md conventions are violated, no new queries or user-facing strings are introduced, and no security concerns are apparent for a plain raster format. LGTM.

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.

🔵 Needs a closer look

The media file route still needs a direct regression test for its separate BMP inline allowlist.

Pull request overview

This PR adds BMP support across media uploads, rendering, admin controls, documentation, and release metadata.

Changes:

  • Adds image/bmp to upload and inline-rendering allowlists.
  • Adds .bmp MIME handling and admin support.
  • Updates tests, documentation, and the changeset.
File summaries
File Summary
packages/core/tests/unit/media/mime.test.ts Tests BMP MIME shorthand support.
packages/core/tests/unit/media/media-allowlist.test.ts Tests BMP upload allowlisting.
packages/core/tests/unit/media/image-endpoint.test.ts Tests inline BMP response headers.
packages/core/src/media/mime.ts Adds .bmp MIME mapping.
packages/core/src/media/image-endpoint.ts Allows BMP inline rendering.
packages/core/src/astro/routes/api/media/file/[...key].ts Allows BMP inline file responses.
packages/core/src/api/handlers/media-allowlist.ts Adds BMP to the default upload allowlist.
packages/admin/src/lib/mime-utils.ts Adds admin-side .bmp support.
packages/admin/src/components/MediaUploadDialog.tsx Enables BMP uploads and previews.
packages/admin/src/components/AllowedTypesEditor.tsx Adds BMP to the Images preset.
docs/src/content/docs/guides/media-library.mdx Documents BMP support.
.changeset/add-bmp-to-allowlist.md Records the package patch release.
Review details

Suppressed comments (1)

packages/core/src/astro/routes/api/media/file/[...key].ts:24

  • This is a separate private allowlist from SAFE_INLINE_IMAGE_TYPES in media/image-endpoint.ts, but the new test only exercises that other set. The existing routes.test.ts suite already calls this GET handler; without a route-level image/bmp assertion, removing this entry would make BMP downloads use Content-Disposition: attachment while all current tests still pass. Add a case there or centralize the two allowlists so the route behavior is covered.
  • Files reviewed: 12/12 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot review on this PR flagged that SAFE_INLINE_TYPES in the
media file route (astro/routes/api/media/file/[...key].ts) is a
separate set from SAFE_INLINE_IMAGE_TYPES in media/image-endpoint.ts,
and only the latter had test coverage. Removing "image/bmp" from the
route's own set would silently regress to Content-Disposition:
attachment for BMP with no test catching it.

Adds a route-level test asserting image/bmp renders inline through
the actual GET handler, plus the SVG-stays-attachment negative case,
using the existing mockMediaContext helper in this file.
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions github-actions Bot added review/needs-rereview Author pushed changes since the last review cla: needed and removed review/needs-review No maintainer or bot review yet labels Sep 11, 2026
@zaochih

zaochih commented Sep 11, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@zaochih

zaochih commented Sep 11, 2026

Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BMP] Upload failed: File type not allowed

2 participants