Skip to content

Commit

Permalink
Merge pull request #42 from experius/feature/DOBO-786
Browse files Browse the repository at this point in the history
[FEATURE][DOBO-786] Make sure that only image filetypes are processed…
  • Loading branch information
iriks-it authored Jul 3, 2024
2 parents d85d5ea + f66460a commit 7088590
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
21 changes: 21 additions & 0 deletions Helper/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*
Expand Down
5 changes: 2 additions & 3 deletions Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function __construct(
array $data = []
) {
$this->settings = $helperSettings;

parent::__construct($filesystem, $logger, $data);
}

Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 7088590

Please sign in to comment.