fix: check share target parent in userfolders mount

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2026-04-10 18:40:18 +02:00
parent b6230eea7f
commit fae8add994
No known key found for this signature in database
GPG key ID: 42B69D8A64526EFB
2 changed files with 8 additions and 10 deletions

View file

@ -9,12 +9,11 @@ declare(strict_types=1);
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
use OC\Files\SetupManager;
use OC\Files\View;
use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\Mount\IMountManager;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\IUser;
use OCP\Share\Events\VerifyMountPointEvent;
@ -30,8 +29,7 @@ class ShareTargetValidator {
public function __construct(
private readonly IManager $shareManager,
private readonly IEventDispatcher $eventDispatcher,
private readonly SetupManager $setupManager,
private readonly IMountManager $mountManager,
private readonly IRootFolder $rootFolder,
) {
$this->folderExistsCache = new CappedMemoryCache();
}
@ -67,8 +65,10 @@ class ShareTargetValidator {
/** @psalm-suppress InternalMethod */
$absoluteParent = $recipientView->getAbsolutePath($parent);
$this->setupManager->setupForPath($absoluteParent);
$parentMount = $this->mountManager->find($absoluteParent);
// the share target always has to be in the users home
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
$parentMount = $userFolder->getMountPoint();
$cached = $this->folderExistsCache->get($parent);
if ($cached !== null) {

View file

@ -9,12 +9,11 @@ declare(strict_types=1);
namespace OCA\Files_Sharing\Tests;
use OC\EventDispatcher\EventDispatcher;
use OC\Files\SetupManager;
use OCA\Files_Sharing\ShareTargetValidator;
use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\Mount\IMountManager;
use OCP\Files\IRootFolder;
use OCP\IUser;
use OCP\Server;
use OCP\Share\Events\VerifyMountPointEvent;
@ -57,8 +56,7 @@ class ShareTargetValidatorTest extends TestCase {
$this->targetValidator = new ShareTargetValidator(
Server::get(IManager::class),
$this->eventDispatcher,
Server::get(SetupManager::class),
Server::get(IMountManager::class),
Server::get(IRootFolder::class),
);
$this->user2 = $this->createMock(IUser::class);
$this->user2->method('getUID')