mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix(tools): honest content-type for edit-metadata pass-through (#350)
edit-metadata writes EXIF tags in place and streams the original bytes back, but the response content-type defaulted to image/jpeg for any format outside a small map. A BMP/PSD/PPM download then claimed to be a JPEG, and the nightly tool-x-format matrix tried to Sharp-decode it and threw "unsupported image format". Map every format validateImageBuffer can report to its real MIME type, and switch the matrix's pixel-decode gate from a fragile denylist to an allowlist of formats this libvips build is guaranteed to decode. Niche raster types streamed back untouched now carry an honest content-type we simply don't pixel-verify. Verified green across all 157 tools x 34 formats with FULL_MATRIX=1.
This commit is contained in:
@@ -45,6 +45,10 @@ const settingsSchema = z.object({
|
||||
|
||||
type Settings = z.infer<typeof settingsSchema>;
|
||||
|
||||
// edit-metadata writes tags in place and streams the ORIGINAL bytes back, so
|
||||
// the download's content-type must match the real format, not a default. A
|
||||
// previous fallback to image/jpeg made a BMP/PSD/PPM download claim to be a
|
||||
// JPEG. Map every format validateImageBuffer can report.
|
||||
const MIME_BY_FORMAT: Record<string, string> = {
|
||||
jpeg: "image/jpeg",
|
||||
png: "image/png",
|
||||
@@ -53,6 +57,26 @@ const MIME_BY_FORMAT: Record<string, string> = {
|
||||
tiff: "image/tiff",
|
||||
gif: "image/gif",
|
||||
heif: "image/heif",
|
||||
bmp: "image/bmp",
|
||||
svg: "image/svg+xml",
|
||||
ico: "image/x-icon",
|
||||
cur: "image/x-icon",
|
||||
psd: "image/vnd.adobe.photoshop",
|
||||
jxl: "image/jxl",
|
||||
jp2: "image/jp2",
|
||||
qoi: "image/qoi",
|
||||
dds: "image/vnd.ms-dds",
|
||||
exr: "image/x-exr",
|
||||
dpx: "image/x-dpx",
|
||||
fits: "image/fits",
|
||||
eps: "application/postscript",
|
||||
pbm: "image/x-portable-bitmap",
|
||||
pgm: "image/x-portable-graymap",
|
||||
ppm: "image/x-portable-pixmap",
|
||||
pfm: "image/x-portable-floatmap",
|
||||
tga: "image/x-tga",
|
||||
cr3: "image/x-canon-cr3",
|
||||
raw: "image/x-dcraw",
|
||||
};
|
||||
|
||||
const BROWSER_PREVIEWABLE = new Set([
|
||||
|
||||
Reference in New Issue
Block a user