Skip to content

Commit 43db205

Browse files
provokateurinbackportbot[bot]
authored andcommitted
fix(ViewOnlyPlugin): Allow COPY and MOVE operations within the same storage
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 41e6ece commit 43db205

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

apps/dav/lib/DAV/ViewOnlyPlugin.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace OCA\DAV\DAV;
1010

11+
use OCA\DAV\Connector\Sabre\Directory;
1112
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
1213
use OCA\DAV\Connector\Sabre\File as DavFile;
1314
use OCA\Files_Versions\Sabre\VersionFile;
@@ -94,6 +95,17 @@ public function checkViewOnly(RequestInterface $request): bool {
9495
break;
9596
case 'COPY':
9697
case 'MOVE':
98+
$destinationPath = $this->server->getCopyAndMoveInfo($request)['destination'];
99+
$destinationParentPath = dirname($destinationPath);
100+
if ($destinationParentPath === '.') {
101+
$destinationParentPath = '';
102+
}
103+
$destinationParent = $this->server->tree->getNodeForPath($destinationParentPath);
104+
// Copy and move operations within the same storage are allowed, because the destination has the same restrictions.
105+
if (($destinationParent instanceof Directory) && $destinationParent->getNode()->getStorage()->getId() === $storage->getId()) {
106+
break;
107+
}
108+
97109
// If download is disabled, we disable the COPY and MOVE methods even if the shareapi_allow_view_without_download is set to true.
98110
if (!$share->canDownload()) {
99111
throw new Forbidden('Access to this shared resource has been denied because its download permission is disabled.');

0 commit comments

Comments
 (0)