From 186e35d9548779f71a7523f923474e7a20b52197 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 8 Jan 2016 10:03:49 +0100 Subject: [PATCH 1/2] Verify the path is a file on avatar update Fixes #21533 Before we just assumed that the passed path was a file. This does not have to be the case. Thus check if it actually is a file before doing any more tests. --- core/avatar/avatarcontroller.php | 3 +++ tests/core/avatar/avatarcontrollertest.php | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/core/avatar/avatarcontroller.php b/core/avatar/avatarcontroller.php index e8139aa50ae..e67f4ae8ba0 100644 --- a/core/avatar/avatarcontroller.php +++ b/core/avatar/avatarcontroller.php @@ -160,6 +160,9 @@ class AvatarController extends Controller { if (isset($path)) { $path = stripslashes($path); $node = $this->userFolder->get($path); + if (!($node instanceof \OCP\Files\File)) { + return new DataResponse(['data' => ['message' => $this->l->t('Please select a file.')]], Http::STATUS_OK, $headers); + } if ($node->getSize() > 20*1024*1024) { return new DataResponse( ['data' => ['message' => $this->l->t('File is too big')]], diff --git a/tests/core/avatar/avatarcontrollertest.php b/tests/core/avatar/avatarcontrollertest.php index 7f69ba0aadb..9e46e1782af 100644 --- a/tests/core/avatar/avatarcontrollertest.php +++ b/tests/core/avatar/avatarcontrollertest.php @@ -323,6 +323,23 @@ class AvatarControllerTest extends \Test\TestCase { $this->assertEquals('notsquare', $response->getData()['data']); } + /** + * Test posting avatar from existing folder + */ + public function testPostAvatarFromNoFile() { + $file = $this->getMock('OCP\Files\Node'); + $this->container['UserFolder'] + ->method('get') + ->with('folder') + ->willReturn($file); + + //Create request return + $response = $this->avatarController->postAvatar('folder'); + + //On correct upload always respond with the notsquare message + $this->assertEquals(['data' => ['message' => 'Please select a file.']], $response->getData()); + } + /** * Test what happens if the upload of the avatar fails */ From 99cf90c8a49f10deb030d636071ad064028d2e1d Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 8 Jan 2016 10:27:55 +0100 Subject: [PATCH 2/2] fix warning box size for avatar change --- settings/css/settings.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/css/settings.css b/settings/css/settings.css index 8805919c96a..0c6c9820ea9 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -17,7 +17,7 @@ input#openid, input#webdav { width:20em; } margin-bottom: 10px; } #avatar .warning { - width: 350px; + width: 100%; } #uploadavatarbutton, #selectavatar,