From bf693ab9798157291f4ce9eb93f6c2c797e01c03 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 5 Sep 2024 00:53:08 +0200 Subject: [PATCH 001/128] Show error if attachment is rejected for having invalid mime type --- src/components/compose.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index d74fc4e5..c0743512 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -584,7 +584,15 @@ function Compose({ const item = items[i]; if (item.kind === 'file') { const file = item.getAsFile(); - if (file && supportedMimeTypes.includes(file.type)) { + if (!file) { + alert(`Could not access the given attachment.`); + return; + } + else if (!supportedMimeTypes.includes(file.type)) { + alert(`Your instance does not allow attachments of type "${file.type}".`); + return; + } + else { files.push(file); } } From 35ef1b58cf0780a65b42f3f8df36770cd5434fba Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 5 Sep 2024 01:05:29 +0200 Subject: [PATCH 002/128] Accept any file if supportedMediaTypes is undefined --- src/components/compose.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index c0743512..c6d0cfe5 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -222,7 +222,7 @@ function Compose({ charactersReservedPerUrl, } = {}, mediaAttachments: { - supportedMimeTypes = [], + supportedMimeTypes, imageSizeLimit, imageMatrixLimit, videoSizeLimit, @@ -588,7 +588,7 @@ function Compose({ alert(`Could not access the given attachment.`); return; } - else if (!supportedMimeTypes.includes(file.type)) { + else if (supportedMimeTypes !== undefined && !supportedMimeTypes.includes(file.type)) { alert(`Your instance does not allow attachments of type "${file.type}".`); return; } @@ -1262,7 +1262,7 @@ function Compose({