From e3cd5edaf729ef810cb4e843edcd606ede8232e4 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 30 Jun 2022 11:44:31 +0300 Subject: [PATCH] ref --- application/Espo/Services/Attachment.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/application/Espo/Services/Attachment.php b/application/Espo/Services/Attachment.php index d6626c87a0..9b14469b0e 100644 --- a/application/Espo/Services/Attachment.php +++ b/application/Espo/Services/Attachment.php @@ -82,16 +82,6 @@ class Attachment extends Record 'TemplateManager', ]; - /** - * @var string[] - */ - protected $imageTypeList = [ - 'image/png', - 'image/jpeg', - 'image/gif', - 'image/webp', - ]; - /** * @param string $fileData * @throws Forbidden @@ -349,9 +339,11 @@ class Attachment extends Record if (isset($data->parentType)) { $relatedEntityType = $data->parentType; - } else if (isset($data->relatedType)) { + } + else if (isset($data->relatedType)) { $relatedEntityType = $data->relatedType; - } else { + } + else { throw new BadRequest(); } @@ -549,7 +541,10 @@ class Attachment extends Record return null; } - if (!in_array($type, $this->imageTypeList)) { + /** @var string[] */ + $imageTypeList = $this->metadata->get(['app', 'image', 'allowedFileTypeList']) ?? []; + + if (!in_array($type, $imageTypeList)) { return null; }