aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2020-10-29 20:11:00 +0100
committerGitHub <noreply@github.com>2020-10-29 20:11:00 +0100
commitb0bfb825c418eafeb264fd3f47aa98770261d480 (patch)
tree82625a3ad340a059734e9e79cca1fa1a25ac33cf
parent9b15b66ec9ac1edb9cb48b38bc71cb147ee429df (diff)
parentde7026f6e4662ff42e0a3c12021a3cee25c5d91f (diff)
downloadnextcloud-server-b0bfb825c418eafeb264fd3f47aa98770261d480.tar.gz
nextcloud-server-b0bfb825c418eafeb264fd3f47aa98770261d480.zip
Merge pull request #23757 from nextcloud/share-not-allowed-name
use file name instead of path in 'not allowed to share' message
-rw-r--r--lib/private/Share20/Manager.php3
-rw-r--r--tests/lib/Share20/ManagerTest.php9
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index a12658f10d7..ded0d13b6d0 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -287,8 +287,7 @@ class Manager implements IManager {
// Check if we actually have share permissions
if (!$share->getNode()->isShareable()) {
- $path = $userFolder->getRelativePath($share->getNode()->getPath());
- $message_t = $this->l->t('You are not allowed to share %s', [$path]);
+ $message_t = $this->l->t('You are not allowed to share %s', [$share->getNode()->getName()]);
throw new GenericShareException($message_t, $message_t, 404);
}
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index a33740834f5..36bc99b1d91 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -601,20 +601,22 @@ class ManagerTest extends \Test\TestCase {
$nonShareAble = $this->createMock(Folder::class);
$nonShareAble->method('isShareable')->willReturn(false);
$nonShareAble->method('getPath')->willReturn('path');
+ $nonShareAble->method('getName')->willReturn('name');
$nonShareAble->method('getOwner')
->willReturn($owner);
$nonShareAble->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, IShare::TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
- $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
- $data[] = [$this->createShare(null, IShare::TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share name', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share name', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share name', true];
$limitedPermssions = $this->createMock(File::class);
$limitedPermssions->method('isShareable')->willReturn(true);
$limitedPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
$limitedPermssions->method('getId')->willReturn(108);
$limitedPermssions->method('getPath')->willReturn('path');
+ $limitedPermssions->method('getName')->willReturn('name');
$limitedPermssions->method('getOwner')
->willReturn($owner);
$limitedPermssions->method('getStorage')
@@ -637,6 +639,7 @@ class ManagerTest extends \Test\TestCase {
$nonMoveableMountPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
$nonMoveableMountPermssions->method('getId')->willReturn(108);
$nonMoveableMountPermssions->method('getPath')->willReturn('path');
+ $nonMoveableMountPermssions->method('getName')->willReturn('name');
$nonMoveableMountPermssions->method('getOwner')
->willReturn($owner);
$nonMoveableMountPermssions->method('getStorage')