diff options
author | Vincent Petry <vincent@nextcloud.com> | 2023-01-12 11:28:03 +0100 |
---|---|---|
committer | Vincent Petry (Rebase PR Action) <PVince81@users.noreply.github.com> | 2023-01-13 09:27:16 +0000 |
commit | ecf6b7667b8457592d6334e88d2bf54aa4834238 (patch) | |
tree | 4c74d17665dbb2c982960299dc0707d79cfa86be /apps/dav/lib | |
parent | b88864b89967cabd78c47d75ee2ff4b1d204934f (diff) | |
download | nextcloud-server-ecf6b7667b8457592d6334e88d2bf54aa4834238.tar.gz nextcloud-server-ecf6b7667b8457592d6334e88d2bf54aa4834238.zip |
Extend ViewOnly DAV plugin to versions endpoint
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/DAV/ViewOnlyPlugin.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/apps/dav/lib/DAV/ViewOnlyPlugin.php b/apps/dav/lib/DAV/ViewOnlyPlugin.php index e0c4e26f598..51e3622142d 100644 --- a/apps/dav/lib/DAV/ViewOnlyPlugin.php +++ b/apps/dav/lib/DAV/ViewOnlyPlugin.php @@ -23,6 +23,7 @@ namespace OCA\DAV\DAV; use OCA\DAV\Connector\Sabre\Exception\Forbidden; use OCA\DAV\Connector\Sabre\File as DavFile; +use OCA\Files_Versions\Sabre\VersionFile; use OCP\Files\NotFoundException; use Psr\Log\LoggerInterface; use Sabre\DAV\Server; @@ -70,11 +71,14 @@ class ViewOnlyPlugin extends ServerPlugin { try { assert($this->server !== null); $davNode = $this->server->tree->getNodeForPath($path); - if (!($davNode instanceof DavFile)) { + if ($davNode instanceof DavFile) { + // Restrict view-only to nodes which are shared + $node = $davNode->getNode(); + } else if ($davNode instanceof VersionFile) { + $node = $davNode->getVersion()->getSourceFile(); + } else { return true; } - // Restrict view-only to nodes which are shared - $node = $davNode->getNode(); $storage = $node->getStorage(); |