Skip to content

Commit 922264f

Browse files
committed
fix: check share target parent in userfolders mount
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent dfaa2c2 commit 922264f

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

apps/files_sharing/lib/ShareTargetValidator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
namespace OCA\Files_Sharing;
1010

1111
use OC\Files\Filesystem;
12-
use OC\Files\SetupManager;
1312
use OC\Files\View;
1413
use OCP\Cache\CappedMemoryCache;
1514
use OCP\EventDispatcher\IEventDispatcher;
1615
use OCP\Files\Config\ICachedMountInfo;
17-
use OCP\Files\Mount\IMountManager;
16+
use OCP\Files\IRootFolder;
1817
use OCP\Files\Mount\IMountPoint;
1918
use OCP\IUser;
2019
use OCP\Share\Events\VerifyMountPointEvent;
@@ -30,8 +29,7 @@ class ShareTargetValidator {
3029
public function __construct(
3130
private readonly IManager $shareManager,
3231
private readonly IEventDispatcher $eventDispatcher,
33-
private readonly SetupManager $setupManager,
34-
private readonly IMountManager $mountManager,
32+
private readonly IRootFolder $rootFolder,
3533
) {
3634
$this->folderExistsCache = new CappedMemoryCache();
3735
}
@@ -67,8 +65,10 @@ public function verifyMountPoint(
6765

6866
/** @psalm-suppress InternalMethod */
6967
$absoluteParent = $recipientView->getAbsolutePath($parent);
70-
$this->setupManager->setupForPath($absoluteParent);
71-
$parentMount = $this->mountManager->find($absoluteParent);
68+
69+
// the share target always has to be in the users home
70+
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
71+
$parentMount = $userFolder->getMountPoint();
7272

7373
$cached = $this->folderExistsCache->get($parent);
7474
if ($cached !== null) {

apps/files_sharing/tests/ShareTargetValidatorTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
namespace OCA\Files_Sharing\Tests;
1010

1111
use OC\EventDispatcher\EventDispatcher;
12-
use OC\Files\SetupManager;
1312
use OCA\Files_Sharing\ShareTargetValidator;
1413
use OCP\Constants;
1514
use OCP\EventDispatcher\IEventDispatcher;
1615
use OCP\Files\Config\ICachedMountInfo;
17-
use OCP\Files\Mount\IMountManager;
16+
use OCP\Files\IRootFolder;
1817
use OCP\IUser;
1918
use OCP\Server;
2019
use OCP\Share\Events\VerifyMountPointEvent;
@@ -57,8 +56,7 @@ protected function setUp(): void {
5756
$this->targetValidator = new ShareTargetValidator(
5857
Server::get(IManager::class),
5958
$this->eventDispatcher,
60-
Server::get(SetupManager::class),
61-
Server::get(IMountManager::class),
59+
Server::get(IRootFolder::class),
6260
);
6361
$this->user2 = $this->createMock(IUser::class);
6462
$this->user2->method('getUID')

0 commit comments

Comments
 (0)