From dcea3058643b280d03f08c4f8260af8da7256ede 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`. --- framework/core/composer.json | 1 + framework/core/src/User/AvatarValidator.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/core/composer.json b/framework/core/composer.json index 4f4abf887..c52546437 100644 --- a/framework/core/composer.json +++ b/framework/core/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/framework/core/src/User/AvatarValidator.php b/framework/core/src/User/AvatarValidator.php index 19ee3ca0e..e6fe0df3b 100644 --- a/framework/core/src/User/AvatarValidator.php +++ b/framework/core/src/User/AvatarValidator.php @@ -80,6 +80,6 @@ class AvatarValidator extends AbstractValidator protected function getAllowedTypes() { - return ['jpeg', 'png', 'bmp', 'gif']; + return ['jpg', 'png', 'bmp', 'gif']; } }