Restore the community photo after reload and reject empty, oversized, SVG, and spoofed uploads.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
adilallo
2026-09-10 15:50:32 -06:00
co-authored by Cursor
parent 6ccc1e8c8e
commit 234f3998ad
18 changed files with 1072 additions and 112 deletions
@@ -1,7 +1,6 @@
import { describe, expect, it } from "vitest";
import {
extensionForMime,
isAllowedMime,
isValidUploadFileId,
maxBytesForPurpose,
} from "../../lib/server/uploads/uploadConstants";
@@ -12,18 +11,6 @@ describe("createFlow upload constants", () => {
expect(maxBytesForPurpose("customMethodAttachment")).toBe(10 * 1024 * 1024);
});
it("isAllowedMime allows images for both purposes", () => {
expect(isAllowedMime("communityAvatar", "image/png")).toBe(true);
expect(isAllowedMime("customMethodAttachment", "image/jpeg")).toBe(true);
});
it("isAllowedMime allows pdf only for customMethodAttachment", () => {
expect(isAllowedMime("communityAvatar", "application/pdf")).toBe(false);
expect(isAllowedMime("customMethodAttachment", "application/pdf")).toBe(
true,
);
});
it("extensionForMime maps common types", () => {
expect(extensionForMime("image/png")).toBe(".png");
expect(extensionForMime("image/jpeg")).toBe(".jpg");