Compare commits

...

1 Commits

Author SHA1 Message Date
Cursor Agent
53cec4c0f2 fix: enforce file-size validation when mime type is missing 2026-04-16 13:08:50 +00:00
2 changed files with 10 additions and 1 deletions

View File

@@ -67,6 +67,15 @@ describe("File Input Utils", () => {
expect(toast.error).toHaveBeenCalledWith(expect.stringContaining("File exceeds 5 MB size limit."));
});
test("should show size error for oversized files even when mime type is empty", async () => {
const files = [new File(["x".repeat(101000)], "large.ico", { type: "" })];
const result = await getAllowedFiles(files, ["ico"], 0.1);
expect(result).toHaveLength(0);
expect(toast.error).toHaveBeenCalledWith(expect.stringContaining("File exceeds 0.1 MB size limit."));
});
test("should convert HEIC files to JPEG", async () => {
const heicFile = new File(["test"], "test.heic", { type: "image/heic" });
const mockConvertedFile = new File(["converted"], "test.jpg", { type: "image/jpeg" });

View File

@@ -21,7 +21,7 @@ export const getAllowedFiles = async (
const convertedFiles: File[] = [];
for (const file of files) {
if (!file || !file.type) {
if (!file) {
continue;
}