]> source.dussan.org Git - nextcloud-server.git/commitdiff
Strip of users home path from share api message 19592/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:27:26 +0000 (20:27 +0000)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Share20/Manager.php
tests/lib/Share20/ManagerTest.php

index c902f2a31e1eaadf6290a8890c2655d72bb6fed0..0c0975bcf85a896131fc6fe3b07e7e892a0c506d 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);
                }
 
@@ -325,7 +326,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 6f46d69d8df16fc4a55edd4d2a71136df3e8f522..cf22ff53bab0b29a70ed99e45a4f3dea0d759cda 100644 (file)
@@ -696,6 +696,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);