aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2023-01-12 11:28:03 +0100
committerVincent Petry (Rebase PR Action) <PVince81@users.noreply.github.com>2023-01-13 09:27:16 +0000
commitecf6b7667b8457592d6334e88d2bf54aa4834238 (patch)
tree4c74d17665dbb2c982960299dc0707d79cfa86be /apps/dav/lib
parentb88864b89967cabd78c47d75ee2ff4b1d204934f (diff)
downloadnextcloud-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.php10
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();