From f66460aaaa16cc7e89748075c633064dd2f96b1e Mon Sep 17 00:00:00 2001 From: Matthijs Iriks Date: Wed, 3 Jul 2024 10:43:49 +0200 Subject: [PATCH] [FEATURE][DOBO-786] Make sure that only image filetypes are processed by Gd2 --- Helper/Settings.php | 21 +++++++++++++++++++++ Image/Adapter/Gd2.php | 5 ++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Helper/Settings.php b/Helper/Settings.php index eb70a3a..e7522b1 100644 --- a/Helper/Settings.php +++ b/Helper/Settings.php @@ -88,6 +88,27 @@ public function getConfigValue($path) ); } + + /** + * This is used for the Gd2 + * + * @return array + */ + public function getImageFiletypes() + { + return [ + 'jpg', + 'jpeg', + 'png', + 'gif', + 'webp', + 'bmp', + 'xpm', + 'xbm', + 'wbmp' + ]; + } + /** * Get extra file types (allowed) * diff --git a/Image/Adapter/Gd2.php b/Image/Adapter/Gd2.php index 9f7efba..ee4df00 100644 --- a/Image/Adapter/Gd2.php +++ b/Image/Adapter/Gd2.php @@ -31,7 +31,6 @@ public function __construct( array $data = [] ) { $this->settings = $helperSettings; - parent::__construct($filesystem, $logger, $data); } @@ -46,7 +45,7 @@ public function open($filename) { $pathInfo = pathinfo($filename); if (key_exists('extension', $pathInfo) - && in_array($pathInfo['extension'], $this->settings->getExtraFiletypes()) + && in_array($pathInfo['extension'], $this->settings->getImageFiletypes()) ) { parent::open($filename); } @@ -66,7 +65,7 @@ public function save($destination = null, $newName = null) $fileName = $this->_prepareDestination($destination, $newName); $pathInfo = pathinfo($fileName); if (key_exists('extension', $pathInfo) - && in_array($pathInfo['extension'], $this->settings->getExtraFiletypes()) + && in_array($pathInfo['extension'], $this->settings->getImageFiletypes()) ) { parent::save($destination, $newName); }