Skip to content

Commit

Permalink
fix(procedures): handle unknown file types in file input validation (#…
Browse files Browse the repository at this point in the history
…13925)

ref: MANAGER-15909
Signed-off-by: Omar ALKABOUSS MOUSSANA <[email protected]>
  • Loading branch information
oalkabouss authored Nov 14, 2024
1 parent a04482a commit 17cf3e5
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ export const FileInput: FunctionComponent<Props> = ({ 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', {
Expand Down

0 comments on commit 17cf3e5

Please sign in to comment.