Skip to content

Commit

Permalink
Validate asset extensions as well as types
Browse files Browse the repository at this point in the history
Adds a parallel configurable list of allowed asset extensions alongside
the list of allowed types.

(cherry picked from commit 66e1294)
  • Loading branch information
zerocrates committed Aug 4, 2023
1 parent 9ea6db0 commit 2a7fb26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions application/config/module.config.php
Expand Up @@ -47,6 +47,13 @@
'image/gif',
'image/webp',
],
'allowed_extensions' => [
'jpeg',
'jpg',
'png',
'gif',
'webp',
],
],
'permissions' => [
'acl_resources' => [
Expand Down
2 changes: 1 addition & 1 deletion application/src/Api/Adapter/AssetAdapter.php
Expand Up @@ -70,7 +70,7 @@ public function hydrate(Request $request, EntityInterface $entity, ErrorStore $e

$tempFile->setSourceName($fileData['file']['name']);
$config = $this->getServiceLocator()->get('Config');
$validator = new Validator($config['api_assets']['allowed_media_types']);
$validator = new Validator($config['api_assets']['allowed_media_types'], $config['api_assets']['allowed_extensions']);
if (!$validator->validate($tempFile, $errorStore)) {
return;
}
Expand Down

0 comments on commit 2a7fb26

Please sign in to comment.