Skip to content

Commit 08a5928

Browse files
Merge pull request #3297 from nextcloud/fix/trashbackend/delete-checks-stable27
2 parents 97fc905 + a175fff commit 08a5928

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/Trash/TrashBackend.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,20 @@ public function removeItem(ITrashItem $item) {
197197
if ($node === null) {
198198
throw new NotFoundException();
199199
}
200-
if ($node->getStorage()->unlink($node->getInternalPath()) === false) {
201-
throw new \Exception('Failed to remove item from trashbin');
202-
}
200+
203201
if (!$this->userHasAccessToPath($item->getUser(), $item->getPath(), Constants::PERMISSION_DELETE)) {
204202
throw new NotPermittedException();
205203
}
206204

205+
$folderPermissions = $this->folderManager->getFolderPermissionsForUser($item->getUser(), (int)$folderId);
206+
if (($folderPermissions & Constants::PERMISSION_DELETE) !== Constants::PERMISSION_DELETE) {
207+
throw new NotPermittedException();
208+
}
209+
210+
if ($node->getStorage()->unlink($node->getInternalPath()) === false) {
211+
throw new \Exception('Failed to remove item from trashbin');
212+
}
213+
207214
$node->getStorage()->getCache()->remove($node->getInternalPath());
208215
if ($item->isRootItem()) {
209216
$this->trashManager->removeItem((int)$folderId, $item->getName(), $item->getDeletedTime());

0 commit comments

Comments
 (0)