Skip to content

Commit c0d4330

Browse files
authored
Merge pull request #19594 from nextcloud/backport/19528/stable16
[stable16] Strip of users home path from share api message
2 parents 10bd654 + 2b0ad3a commit c0d4330

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

lib/private/Share20/Manager.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ protected function generalCreateChecks(\OCP\Share\IShare $share) {
281281

282282
// Check if we actually have share permissions
283283
if (!$share->getNode()->isShareable()) {
284-
$message_t = $this->l->t('You are not allowed to share %s', [$share->getNode()->getPath()]);
284+
$path = $userFolder->getRelativePath($share->getNode()->getPath());
285+
$message_t = $this->l->t('You are not allowed to share %s', [$path]);
285286
throw new GenericShareException($message_t, $message_t, 404);
286287
}
287288

@@ -323,7 +324,8 @@ protected function generalCreateChecks(\OCP\Share\IShare $share) {
323324

324325
// Check that we do not share with more permissions than we have
325326
if ($share->getPermissions() & ~$permissions) {
326-
$message_t = $this->l->t('Can’t increase permissions of %s', [$share->getNode()->getPath()]);
327+
$path = $userFolder->getRelativePath($share->getNode()->getPath());
328+
$message_t = $this->l->t('Can’t increase permissions of %s', [$path]);
327329
throw new GenericShareException($message_t, $message_t, 404);
328330
}
329331

tests/lib/Share20/ManagerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ public function testGeneralChecks($share, $exceptionMessage, $exception) {
664664

665665
$userFolder = $this->createMock(Folder::class);
666666
$userFolder->method('getPath')->willReturn('myrootfolder');
667+
$userFolder->expects($this->any())
668+
->method('getRelativePath')
669+
->willReturnArgument(0);
667670
$this->rootFolder->method('getUserFolder')->willReturn($userFolder);
668671

669672

0 commit comments

Comments
 (0)