summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRoeland Douma <rullzer@users.noreply.github.com>2015-07-31 07:31:24 +0200
committerRoeland Douma <rullzer@users.noreply.github.com>2015-07-31 07:31:24 +0200
commitdb91b4505ccd105f03cd23ac91e66b4b48b0b38d (patch)
treea63efec5284e0ff8d52d78225285792edf3815d8 /core
parent519fcee15f50ceea6ee6245f5a49b36cb6c05f4f (diff)
parente184157684ad923d5d4107b76d6421e6ae28799d (diff)
downloadnextcloud-server-db91b4505ccd105f03cd23ac91e66b4b48b0b38d.tar.gz
nextcloud-server-db91b4505ccd105f03cd23ac91e66b4b48b0b38d.zip
Merge pull request #17805 from owncloud/avatar-handle-errors
[avatar] add error handlers for avatar setup
Diffstat (limited to 'core')
-rw-r--r--core/avatar/avatarcontroller.php8
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');