mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix(image): validate caire settings as integers (#680)
caire's -width/-height/-blur/-sobel flags are integer-only; a schema-valid float crashed the binary and surfaced as a corrupt-file 422. Reject fractional values at validation time with a settings-shaped 400. Fixes #672.
This commit is contained in:
@@ -57,6 +57,27 @@ describe("Content-Aware Resize", () => {
|
||||
expect([200, 422]).toContain(res.statusCode);
|
||||
}, 60_000);
|
||||
|
||||
it("rejects fractional values for caire's integer-only flags", async () => {
|
||||
for (const settings of [
|
||||
{ width: 100.5 },
|
||||
{ height: 80.25 },
|
||||
{ blurRadius: 2.5 },
|
||||
{ sobelThreshold: 10.5 },
|
||||
]) {
|
||||
const { body, contentType } = createMultipartPayload([
|
||||
{ name: "file", filename: "test.png", contentType: "image/png", content: PNG_200x150 },
|
||||
{ name: "settings", content: JSON.stringify(settings) },
|
||||
]);
|
||||
const res = await app.inject({
|
||||
method: "POST",
|
||||
url: "/api/v1/tools/image/content-aware-resize",
|
||||
headers: { authorization: `Bearer ${adminToken}`, "content-type": contentType },
|
||||
body,
|
||||
});
|
||||
expect(res.statusCode, JSON.stringify(settings)).toBe(400);
|
||||
}
|
||||
}, 60_000);
|
||||
|
||||
it("rejects requests without a file", async () => {
|
||||
const { body, contentType } = createMultipartPayload([
|
||||
{ name: "settings", content: JSON.stringify({ width: 150 }) },
|
||||
|
||||
Reference in New Issue
Block a user