diff --git a/js/src/forum/components/AvatarEditor.js b/js/src/forum/components/AvatarEditor.js
index 880b0a4df..f48d4c0d6 100644
--- a/js/src/forum/components/AvatarEditor.js
+++ b/js/src/forum/components/AvatarEditor.js
@@ -149,7 +149,7 @@ export default class AvatarEditor extends Component {
// Create a hidden HTML input element and click on it so the user can select
// an avatar file. Once they have, we will upload it via the API.
- const $input = $('');
+ const $input = $('');
$input
.appendTo('body')
diff --git a/src/User/AvatarValidator.php b/src/User/AvatarValidator.php
index f9689b239..5a0a1cad2 100644
--- a/src/User/AvatarValidator.php
+++ b/src/User/AvatarValidator.php
@@ -11,6 +11,8 @@ namespace Flarum\User;
use Flarum\Foundation\AbstractValidator;
use Flarum\Foundation\ValidationException;
+use Intervention\Image\Exception\NotReadableException;
+use Intervention\Image\ImageManager;
use Psr\Http\Message\UploadedFileInterface;
use Symfony\Component\Mime\MimeTypes;
@@ -69,6 +71,12 @@ class AvatarValidator extends AbstractValidator
if (! in_array($guessedExtension, $allowedTypes)) {
$this->raise('mimes', [':values' => implode(', ', $allowedTypes)]);
}
+
+ try {
+ (new ImageManager)->make($file->getStream());
+ } catch (NotReadableException $_e) {
+ $this->raise('image');
+ }
}
protected function assertFileSize(UploadedFileInterface $file)
@@ -103,6 +111,6 @@ class AvatarValidator extends AbstractValidator
protected function getAllowedTypes()
{
- return ['jpg', 'png', 'bmp', 'gif'];
+ return ['jpeg', 'jpg', 'png', 'bmp', 'gif'];
}
}