mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: add exotic format decoding to image-to-pdf tool
The image-to-pdf route used ensureSharpCompat (HEIC-only) instead of the full format decode pipeline from tool-factory. Formats like FITS, PSD, RAW, EXR, HDR, TGA, etc. passed through undecoded and crashed Sharp. Replace with validateImageBuffer + decodeToSharpCompat to match the standard tool pipeline.
This commit is contained in:
@@ -216,7 +216,7 @@ describe("image-to-pdf", () => {
|
||||
|
||||
// ── Branch coverage: lines 143-147 (processing failure) ───────────
|
||||
|
||||
it("returns 422 when processing fails on corrupted image data", async () => {
|
||||
it("returns 400 when image format is unrecognized", async () => {
|
||||
const corruptedBuffer = Buffer.alloc(100, 0xff);
|
||||
const { body, contentType } = createMultipartPayload([
|
||||
{ name: "file", filename: "bad.png", contentType: "image/png", content: corruptedBuffer },
|
||||
@@ -230,9 +230,9 @@ describe("image-to-pdf", () => {
|
||||
body,
|
||||
});
|
||||
|
||||
expect(res.statusCode).toBe(422);
|
||||
expect(res.statusCode).toBe(400);
|
||||
const json = JSON.parse(res.body);
|
||||
expect(json.error).toContain("PDF creation failed");
|
||||
expect(json.error).toContain("Invalid image");
|
||||
});
|
||||
|
||||
// ── HEIC input handling ───────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user