From baf5f38a25eeabc0893ad2a3eeeb39b58404b7b3 Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 9 Jan 2024 01:05:33 +0000 Subject: [PATCH] [core] only check image contents if the mime type is one we can handle --- core/extension.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/extension.php b/core/extension.php index 4fd42e32..31c41f88 100644 --- a/core/extension.php +++ b/core/extension.php @@ -301,9 +301,12 @@ abstract class DataHandlerExtension extends Extension public function onDataUpload(DataUploadEvent $event) { - $supported_mime = $this->supported_mime($event->mime); - $check_contents = $this->check_contents($event->tmpname); - if ($supported_mime && $check_contents) { + if ($this->supported_mime($event->mime)) { + if (!$this->check_contents($event->tmpname)) { + // We DO support this extension - but the file looks corrupt + throw new UploadException("Invalid or corrupted file"); + } + $this->move_upload_to_archive($event); /* Check if we are replacing an image */ @@ -348,9 +351,6 @@ abstract class DataHandlerExtension extends Extension send_event(new LockSetEvent($image, $event->metadata['locked'])); } } - } elseif ($supported_mime && !$check_contents) { - // We DO support this extension - but the file looks corrupt - throw new UploadException("Invalid or corrupted file"); } }