From 17cf3e5c60647ab76f622ee57dd7c2828711742b Mon Sep 17 00:00:00 2001 From: Omar Date: Thu, 14 Nov 2024 17:36:39 +0100 Subject: [PATCH] fix(procedures): handle unknown file types in file input validation (#13925) ref: MANAGER-15909 Signed-off-by: Omar ALKABOUSS MOUSSANA --- .../procedures/src/components/FileInput/FileInput.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/manager/apps/procedures/src/components/FileInput/FileInput.tsx b/packages/manager/apps/procedures/src/components/FileInput/FileInput.tsx index 58bc7be757f5..8829498d0434 100644 --- a/packages/manager/apps/procedures/src/components/FileInput/FileInput.tsx +++ b/packages/manager/apps/procedures/src/components/FileInput/FileInput.tsx @@ -45,9 +45,16 @@ export const FileInput: FunctionComponent = ({ className }) => { }; const mapToFilesWithError = (files: File[]): FileWithError[] => { + const allowedTypes = accept + .split(',') + .map((type) => type.trim().toLocaleLowerCase()) + .filter(Boolean); + return files.map((fileItem) => { const errorMessages: string[] = []; - if (!accept.includes(fileItem.type)) { + const fileType = fileItem.type?.toLocaleLowerCase(); + + if (allowedTypes.length > 0 && !allowedTypes.includes(fileType)) { const { types, lastType } = parseContentTypes(accept); errorMessages.push( t('account-disable-2fa-file-input-type-file-error', {