Skip to content

Commit a175fff

Browse files
committed
fix(TrashBackend): Fix delete checks
Signed-off-by: provokateurin <[email protected]>
1 parent 97fc905 commit a175fff

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)