From 12252b96304ea37c72eee0323d8d4639ee3561bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Tue, 15 Dec 2020 08:36:53 +0100 Subject: [PATCH] Fixes validation failures of avatars that are jpg/jpeg Due to a commit by @fabpot in october, the mimetypes symfony class now re-orders the shortened mimetypes that are returned when looking up based on header mimetype. Our validator uses the first key, pops the prefix off and then matches against our hardcoded array. I've added a constraint to symfony/mime ^5.2.0 which ships with this change. This constraint is fully compatible with our current lineup. In addition I changed the hardcoded array to use the first entry from symfony mime types now `jpg` instead of `jpeg`. This change has been locally tested and confirmed fixed. --- composer.json | 1 + src/User/AvatarValidator.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4f4abf8878..c525464374 100644 --- a/composer.json +++ b/composer.json @@ -79,6 +79,7 @@ "symfony/config": "^4.3.4", "symfony/console": "^4.3.4", "symfony/event-dispatcher": "^4.3.4", + "symfony/mime": "^5.2.0", "symfony/translation": "^4.3.4", "symfony/yaml": "^4.3.4", "tobscure/json-api": "^0.3.0", diff --git a/src/User/AvatarValidator.php b/src/User/AvatarValidator.php index 19ee3ca0ee..e6fe0df3b7 100644 --- a/src/User/AvatarValidator.php +++ b/src/User/AvatarValidator.php @@ -80,6 +80,6 @@ protected function getMaxSize() protected function getAllowedTypes() { - return ['jpeg', 'png', 'bmp', 'gif']; + return ['jpg', 'png', 'bmp', 'gif']; } }