From 5e2741f8f7bcebc08dcbe3a0aa7003d40f9acaf9 Mon Sep 17 00:00:00 2001 From: kyrers Date: Thu, 11 Dec 2025 15:35:35 +0000 Subject: [PATCH] fix: enhance file type validation in AtlasProvider to support wildcard MIME types --- kleros-app/src/lib/atlas/providers/AtlasProvider.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx b/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx index f4b646d7e..fa3940e28 100644 --- a/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx +++ b/kleros-app/src/lib/atlas/providers/AtlasProvider.tsx @@ -281,7 +281,16 @@ export const AtlasProvider: React.FC<{ config: AtlasConfig; children?: React.Rea const restrictions = roleRestrictions.find((supportedRoles) => Roles[supportedRoles.name] === role); if (!restrictions) throw new Error("Unsupported role."); - if (!restrictions.restriction.allowedMimeTypes.includes(file.type)) throw new Error("Unsupported file type."); + + const isValidMimeType = restrictions.restriction.allowedMimeTypes.some((allowedType) => { + if (allowedType.endsWith("/*")) { + const prefix = allowedType.replace("/*", "/"); + return file.type.startsWith(prefix); + } + return allowedType === file.type; + }); + + if (!isValidMimeType) throw new Error("Unsupported file type."); if (file.size > restrictions.restriction.maxSize) throw new Error( `File too big. Max allowed size : ${(restrictions.restriction.maxSize / (1024 * 1024)).toFixed(2)} mb.`