From 568a376f2b1ea9d11b354422779041a6e28dc524 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 26 Sep 2024 16:34:45 +0200 Subject: [PATCH] fix(TrashBackend): Fix delete checks Signed-off-by: provokateurin --- lib/Trash/TrashBackend.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index cf847253d..10a9adf93 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -184,14 +184,19 @@ public function removeItem(ITrashItem $item): void { throw new NotFoundException(); } - if ($node->getStorage()->unlink($node->getInternalPath()) === false) { - throw new \Exception('Failed to remove item from trashbin'); + if (!$this->userHasAccessToPath($item->getUser(), $item->getPath(), Constants::PERMISSION_DELETE)) { + throw new NotPermittedException(); } - if (!$this->userHasAccessToPath($item->getUser(), $item->getPath(), Constants::PERMISSION_DELETE)) { + $folderPermissions = $this->folderManager->getFolderPermissionsForUser($item->getUser(), (int)$folderId); + if (($folderPermissions & Constants::PERMISSION_DELETE) !== Constants::PERMISSION_DELETE) { throw new NotPermittedException(); } + if ($node->getStorage()->unlink($node->getInternalPath()) === false) { + throw new \Exception('Failed to remove item from trashbin'); + } + $node->getStorage()->getCache()->remove($node->getInternalPath()); if ($item->isRootItem()) { $this->trashManager->removeItem((int)$folderId, $item->getName(), $item->getDeletedTime());