From 7b1b161280b8fe5b337969b94ac8a63e255b1d41 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 14 Mar 2019 16:18:43 +0100 Subject: [PATCH] dont try to restore a trashbin item to a readonly target Signed-off-by: Robin Appelman --- apps/files_trashbin/lib/Trashbin.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 5adbdeca6a..8fc99c637a 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -48,6 +48,7 @@ use OCA\Files_Trashbin\Command\Expire; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\User; class Trashbin { @@ -414,6 +415,9 @@ class Trashbin { $mtime = $view->filemtime($source); // restore file + if (!$view->isCreatable(dirname($target))) { + throw new NotPermittedException("Can't restore trash item because the target folder is not writable"); + } $restoreResult = $view->rename($source, $target); // handle the restore result