]> source.dussan.org Git - nextcloud-server.git/commitdiff
Strip of users home path from share api message 19594/head
authorJoas Schilling <coding@schilljs.com>
Tue, 18 Feb 2020 10:02:11 +0000 (11:02 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Sat, 22 Feb 2020 20:28:26 +0000 (20:28 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Share20/Manager.php
tests/lib/Share20/ManagerTest.php

index dd983b6c7ba007dec4ed3121641e1c5411244496..eec489a0e2bec1e212dc9eb89e5818c0091f37a6 100644 (file)
@@ -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);
                }
 
index 170c58769db9e9b7d775a3c84b967a9904bab0e3..6e06434d31af682aba591dc0b861f6cba3b1dd32 100644 (file)
@@ -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);