mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5176] [MERGED] fix(gallery): serve mislabeled raster images by detected MIME type #6660
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6660
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5176
Author: @Gunterlie
Created: 8/17/2026
Status: ✅ Merged
Merged: 8/17/2026
Merged by: @Gunterlie
Base:
staging← Head:issue-392-marinara-agents📝 Commits (3)
fc70614fix(gallery): serve mislabeled raster images by detected MIME typea2cfc6edocs(changelog): note gallery MIME fix89d7fadfix(media): detect mislabeled AVIF images📊 Changes
4 files changed (+46 additions, -7 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/utils/media-file-security.ts(+4 -5)📝
packages/server/src/utils/security.ts(+1 -2)➕
scripts/regressions/gallery-mislabeled-raster.regression.ts(+40 -0)📄 Description
Why
Since Marinara Engine v2.4.2, the Noodle feed renders generated post images as broken-image icons (reported in Pasta-Devs/Marinara-Agents#392). The main app (Slurp) is unaffected. The file exists on disk, the
character_imagesrow exists, andimageUrlpoints at the file — generation and bookkeeping succeed. The failure is purely on the serve side.Root cause: v2.4.2 hardened the character-gallery serve route (
GET /api/characters/:id/gallery/file/:filename), replacingreply.sendFile(...)withvalidateImageAssetFile()+sendValidatedMediaFile().validateImageAssetBufferrejected any file whose extension disagreed with its magic-byte format. The Noodle package copies generated post images intogallery/characters/<id>/with a hardcoded.pngname, but theqwen-imageprovider returns WebP/JPEG bytes — so the mislabeled files now 404. Under v2.4.1reply.sendFileserved them and the browser sniffed the content and rendered them. The two suspects in the issue (#4754 gallery sharding, #4763 Noodle packaging) are red herrings.What
Serve any recognized raster image by its detected MIME type instead of requiring
extension == content. Content-Type stays honest. Raster formats are inert, so this is safe; SVG validation stays strict (SVG is scriptable). This heals already-generated broken files and fixes the character-, persona-, and chat-gallery serve routes in one place, since all route throughvalidateImageAssetBuffer.packages/server/src/utils/media-file-security.ts— relax raster ext/content agreement; remove now-unusednormalizedRasterExtension.scripts/regressions/gallery-mislabeled-raster.regression.ts— new regression.Follow-up
The mislabeling originates in the Noodle package. A companion issue is filed on
Pasta-Devs/Marinara-Agentsto write the correct extension from the response bytes at the source.Validation
pnpm checknode ./scripts/run-regressions.mjs --filter scripts/regressions/gallery-mislabeled-raster.regression.tsdata/gallery/characters/<id>/<name>.pngwith a matchingcharacter_imagesrow serves HTTP 200 withContent-Type: image/webpat/api/characters/<id>/gallery/file/<name>.png(previously 404).Content-Type: image/png.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.