diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-07-22 13:13:39 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-30 18:05:32 +0200 |
commit | e184157684ad923d5d4107b76d6421e6ae28799d (patch) | |
tree | 41ac7f0569caf96c75657e8dd6858222db2f37b1 /core/avatar | |
parent | a07254856ce532bfe5c49c1b53247daf88dbdd4a (diff) | |
download | nextcloud-server-e184157684ad923d5d4107b76d6421e6ae28799d.tar.gz nextcloud-server-e184157684ad923d5d4107b76d6421e6ae28799d.zip |
[avatar] add error handlers for avatar setup
add colon to translated string
use placeholder in t()
Adding a size limitation for avatar upload
Unit test for file size
Fix typo & display server side error message
Diffstat (limited to 'core/avatar')
-rw-r--r-- | core/avatar/avatarcontroller.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/avatar/avatarcontroller.php b/core/avatar/avatarcontroller.php index 95baf23f4fa..2c4be827738 100644 --- a/core/avatar/avatarcontroller.php +++ b/core/avatar/avatarcontroller.php @@ -134,6 +134,10 @@ class AvatarController extends Controller { if (isset($path)) { $path = stripslashes($path); $view = new \OC\Files\View('/'.$userId.'/files'); + if ($view->filesize($path) > 20*1024*1024) { + return new DataResponse(['data' => ['message' => $this->l->t('File is too big')]], + Http::STATUS_BAD_REQUEST); + } $fileName = $view->getLocalFile($path); } elseif (!is_null($files)) { if ( @@ -141,6 +145,10 @@ class AvatarController extends Controller { is_uploaded_file($files['tmp_name'][0]) && !\OC\Files\Filesystem::isFileBlacklisted($files['tmp_name'][0]) ) { + if ($files['size'][0] > 20*1024*1024) { + return new DataResponse(['data' => ['message' => $this->l->t('File is too big')]], + Http::STATUS_BAD_REQUEST); + } $this->cache->set('avatar_upload', file_get_contents($files['tmp_name'][0]), 7200); $view = new \OC\Files\View('/'.$userId.'/cache'); $fileName = $view->getLocalFile('avatar_upload'); |