fix: harden share bot uploads

This commit is contained in:
2026-08-16 01:13:47 +07:00 Unverified
parent c2af37efaa
commit a9f91d6a13
4 changed files with 104 additions and 8 deletions
+8 -2
View File
@@ -24,8 +24,9 @@ describe("share validation", () => {
throw new Error("Expected blank text to fail");
} catch (error) {
expect(error).toBeInstanceOf(ShareHttpError);
expect((error as ShareHttpError).status).toBe(422);
expect((error as ShareHttpError).status).toBe(400);
}
expect(() => validateShareText("before\0after")).toThrow("NUL");
});
test("measures the text limit in UTF-8 bytes", () => {
@@ -65,7 +66,12 @@ describe("share validation", () => {
type: "text/plain",
})
)
).rejects.toMatchObject({ status: 422 });
).rejects.toMatchObject({ status: 400 });
await expect(
validateTextFile(
new File(["before\0after"], "nul.txt", { type: "text/plain" })
)
).rejects.toMatchObject({ status: 400 });
});
test("validates image contents instead of trusting the MIME type", async () => {