From 2b0ad3a9cf70ab610a15d604c98493723b00a8f5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 18 Feb 2020 11:02:11 +0100 Subject: [PATCH] Strip of users home path from share api message Signed-off-by: Joas Schilling --- lib/private/Share20/Manager.php | 6 ++++-- tests/lib/Share20/ManagerTest.php | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index dd983b6c7b..eec489a0e2 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -281,7 +281,8 @@ class Manager implements IManager { // Check if we actually have share permissions if (!$share->getNode()->isShareable()) { - $message_t = $this->l->t('You are not allowed to share %s', [$share->getNode()->getPath()]); + $path = $userFolder->getRelativePath($share->getNode()->getPath()); + $message_t = $this->l->t('You are not allowed to share %s', [$path]); throw new GenericShareException($message_t, $message_t, 404); } @@ -323,7 +324,8 @@ class Manager implements IManager { // Check that we do not share with more permissions than we have if ($share->getPermissions() & ~$permissions) { - $message_t = $this->l->t('Can’t increase permissions of %s', [$share->getNode()->getPath()]); + $path = $userFolder->getRelativePath($share->getNode()->getPath()); + $message_t = $this->l->t('Can’t increase permissions of %s', [$path]); throw new GenericShareException($message_t, $message_t, 404); } diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 170c58769d..6e06434d31 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -664,6 +664,9 @@ class ManagerTest extends \Test\TestCase { $userFolder = $this->createMock(Folder::class); $userFolder->method('getPath')->willReturn('myrootfolder'); + $userFolder->expects($this->any()) + ->method('getRelativePath') + ->willReturnArgument(0); $this->rootFolder->method('getUserFolder')->willReturn($userFolder);