From: Alexander Ebert Date: Tue, 3 Dec 2024 15:14:14 +0000 (+0100) Subject: Add proper error handling for damaged images X-Git-Tag: 6.1.2_dev_1~6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=22306e1576cc80943b8d913aed0287d82d912499;p=GitHub%2FWoltLab%2FWCF.git Add proper error handling for damaged images --- diff --git a/ts/WoltLabSuite/Core/Component/File/Upload.ts b/ts/WoltLabSuite/Core/Component/File/Upload.ts index e43ccb5c4d..476a94d6f9 100644 --- a/ts/WoltLabSuite/Core/Component/File/Upload.ts +++ b/ts/WoltLabSuite/Core/Component/File/Upload.ts @@ -268,9 +268,13 @@ export function setup(): void { return; } - void resizeImage(element, file).then((resizedFile) => { - void upload(element, resizedFile); - }); + void resizeImage(element, file) + .then((resizedFile) => { + void upload(element, resizedFile); + }) + .catch(() => { + innerError(element, getPhrase("wcf.upload.error.damagedImageFile", { filename: file.name })); + }); }); element.addEventListener("ckeditorDrop", (event: CustomEvent) => { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js index 1dad3ed9be..fc70bf44f2 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js @@ -183,8 +183,12 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/Selector", "Wol else if (!validateFileSize(element, file)) { return; } - void resizeImage(element, file).then((resizedFile) => { + void resizeImage(element, file) + .then((resizedFile) => { void upload(element, resizedFile); + }) + .catch(() => { + (0, Util_1.innerError)(element, (0, Language_1.getPhrase)("wcf.upload.error.damagedImageFile", { filename: file.name })); }); }); element.addEventListener("ckeditorDrop", (event) => { diff --git a/wcfsetup/install/files/lib/system/event/listener/PreloadPhrasesCollectingListener.class.php b/wcfsetup/install/files/lib/system/event/listener/PreloadPhrasesCollectingListener.class.php index 6bced647c0..13c7e60ae6 100644 --- a/wcfsetup/install/files/lib/system/event/listener/PreloadPhrasesCollectingListener.class.php +++ b/wcfsetup/install/files/lib/system/event/listener/PreloadPhrasesCollectingListener.class.php @@ -150,6 +150,7 @@ final class PreloadPhrasesCollectingListener $event->preload('wcf.style.changeStyle'); + $event->preload('wcf.upload.error.damagedImageFile'); $event->preload('wcf.upload.error.fileExtensionNotPermitted'); $event->preload('wcf.upload.error.fileSizeTooLarge'); $event->preload('wcf.upload.error.maximumCountReached'); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 96f2048974..13e4b84f09 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -5562,6 +5562,7 @@ Benachrichtigungen auf {PAGE_TITLE|phra + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index e9dad53624..770ce9fd83 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -5564,6 +5564,7 @@ your notifications on {PAGE_TITLE|phras +