From 06e1d213316e3c5296b516087021c6bcd173a9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Wed, 16 Dec 2020 19:53:17 +0100 Subject: [PATCH] Fixes validation failures of avatars that are jpg/jpeg (#2497) 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`. --- 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']; } }