From 79e48941e0a26dc6b8eae20ba4e22ec002a8e720 Mon Sep 17 00:00:00 2001 From: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com> Date: Tue, 16 Sep 2025 17:08:23 +0200 Subject: [PATCH] fix: isPublicShare =true when share is public The isPublicShare was set to false in one instance where it should have been true. Flipping the value to true, would break the functionality for PROPFIND /public.php/webdav/ which returns properties of files in a share identified by the username being the share token. Signed-off-by: Salvatore Martire <4652631+salmart-dev@users.noreply.github.com> --- apps/dav/appinfo/v1/publicwebdav.php | 11 ++++++++++- apps/dav/lib/Connector/Sabre/ServerFactory.php | 13 +++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php index af49ca5462c..8bc170f2630 100644 --- a/apps/dav/appinfo/v1/publicwebdav.php +++ b/apps/dav/appinfo/v1/publicwebdav.php @@ -68,7 +68,16 @@ $requestUri = Server::get(IRequest::class)->getRequestUri(); $linkCheckPlugin = new PublicLinkCheckPlugin(); $filesDropPlugin = new FilesDropPlugin(); -$server = $serverFactory->createServer(false, $baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) { +$server = $serverFactory->createServer( + true, + $baseuri, + $requestUri, + $authPlugin, + function (\Sabre\DAV\Server $server) use ( + $authBackend, + $linkCheckPlugin, + $filesDropPlugin + ) { $isAjax = in_array('XMLHttpRequest', explode(',', $_SERVER['HTTP_X_REQUESTED_WITH'] ?? '')); /** @var FederatedShareProvider $shareProvider */ $federatedShareProvider = Server::get(FederatedShareProvider::class); diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php index c86d22956be..7a8f6fd032a 100644 --- a/apps/dav/lib/Connector/Sabre/ServerFactory.php +++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php @@ -71,8 +71,13 @@ class ServerFactory { Plugin $authPlugin, callable $viewCallBack, ): Server { + // /public.php/webdav/ shows the files in the share in the root itself + // and not under /public.php/webdav/files/{token} so we should keep + // compatibility for that. + $needsSharesInRoot = $baseUri === '/public.php/webdav/'; + $useCollection = $isPublicShare && !$needsSharesInRoot; $debugEnabled = $this->config->getSystemValue('debug', false); - [$tree, $rootCollection] = $this->getTree($isPublicShare); + [$tree, $rootCollection] = $this->getTree($useCollection); $server = new Server($tree); // Set URL explicitly due to reverse-proxy situations $server->httpRequest->setUrl($requestUri); @@ -121,8 +126,8 @@ class ServerFactory { } // wait with registering these until auth is handled and the filesystem is setup - $server->on('beforeMethod:*', function () use ($server, $tree, - $viewCallBack, $rootCollection, $debugEnabled): void { + $server->on('beforeMethod:*', function () use ($server, + $tree, $viewCallBack, $isPublicShare, $rootCollection, $debugEnabled): void { // ensure the skeleton is copied $userFolder = \OC::$server->getUserFolder(); @@ -157,7 +162,7 @@ class ServerFactory { $this->userSession, \OCP\Server::get(IFilenameValidator::class), \OCP\Server::get(IAccountManager::class), - false, + $isPublicShare, !$debugEnabled ) );