Added stricter validation to user avatars
This commit is contained in:
parent
cd146e0750
commit
b01adce156
1 changed files with 10 additions and 0 deletions
|
@ -38,6 +38,16 @@ class UserEditFormData implements \Szurubooru\IValidatable
|
||||||
if ($this->email !== null)
|
if ($this->email !== null)
|
||||||
$validator->validateEmail($this->email);
|
$validator->validateEmail($this->email);
|
||||||
|
|
||||||
|
if (strlen($this->avatarContent) > 1024 * 512)
|
||||||
|
throw new \DomainException('Avatar content must have at most 512 kilobytes.');
|
||||||
|
|
||||||
|
if ($this->avatarContent)
|
||||||
|
{
|
||||||
|
$avatarContentMimeType = \Szurubooru\Helpers\MimeHelper::getMimeTypeFromBuffer($this->avatarContent);
|
||||||
|
if (!\Szurubooru\Helpers\MimeHelper::isImage($avatarContentMimeType))
|
||||||
|
throw new \DomainException('Avatar must be an image (detected: ' . $avatarContentMimeType . ').');
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->browsingSettings !== null)
|
if ($this->browsingSettings !== null)
|
||||||
{
|
{
|
||||||
if (!is_string($this->browsingSettings))
|
if (!is_string($this->browsingSettings))
|
||||||
|
|
Loading…
Reference in a new issue