Merge pull request #19594 from nextcloud/backport/19528/stable16

[stable16] Strip of users home path from share api message
This commit is contained in:
Roeland Jago Douma 2020-02-23 11:38:43 +01:00 committed by GitHub
commit c0d4330360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View 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('Cant increase permissions of %s', [$share->getNode()->getPath()]);
$path = $userFolder->getRelativePath($share->getNode()->getPath());
$message_t = $this->l->t('Cant increase permissions of %s', [$path]);
throw new GenericShareException($message_t, $message_t, 404);
}

View 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);