Skip to content

Commit 8b9475f

Browse files
committed
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.
1 parent cc67cf3 commit 8b9475f

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

apps/dav/appinfo/v1/publicwebdav.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,16 @@
6868
$linkCheckPlugin = new PublicLinkCheckPlugin();
6969
$filesDropPlugin = new FilesDropPlugin();
7070

71-
$server = $serverFactory->createServer(false, $baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
71+
$server = $serverFactory->createServer(
72+
true,
73+
$baseuri,
74+
$requestUri,
75+
$authPlugin,
76+
function (\Sabre\DAV\Server $server) use (
77+
$authBackend,
78+
$linkCheckPlugin,
79+
$filesDropPlugin
80+
) {
7281
$isAjax = in_array('XMLHttpRequest', explode(',', $_SERVER['HTTP_X_REQUESTED_WITH'] ?? ''));
7382
/** @var FederatedShareProvider $shareProvider */
7483
$federatedShareProvider = Server::get(FederatedShareProvider::class);

apps/dav/lib/Connector/Sabre/ServerFactory.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@ public function createServer(
7070
Plugin $authPlugin,
7171
callable $viewCallBack,
7272
): Server {
73+
// /public.php/webdav/ shows the files in the share in the root itself
74+
// and not under /public.php/webdav/files/{token} so we should keep
75+
// compatibility for that.
76+
$needsSharesInRoot = $baseUri === '/public.php/webdav/';
77+
$useCollection = $isPublicShare && !$needsSharesInRoot;
7378
$debugEnabled = $this->config->getSystemValue('debug', false);
74-
[$tree, $rootCollection] = $this->getTree($isPublicShare);
79+
[$tree, $rootCollection] = $this->getTree($useCollection);
7580
$server = new Server($tree);
7681
// Set URL explicitly due to reverse-proxy situations
7782
$server->httpRequest->setUrl($requestUri);
@@ -120,8 +125,8 @@ public function createServer(
120125
}
121126

122127
// wait with registering these until auth is handled and the filesystem is setup
123-
$server->on('beforeMethod:*', function () use ($server, $tree,
124-
$viewCallBack, $rootCollection, $debugEnabled): void {
128+
$server->on('beforeMethod:*', function () use ($server,
129+
$tree, $viewCallBack, $isPublicShare, $rootCollection, $debugEnabled): void {
125130
// ensure the skeleton is copied
126131
$userFolder = \OC::$server->getUserFolder();
127132

@@ -156,7 +161,7 @@ public function createServer(
156161
$this->userSession,
157162
\OCP\Server::get(IFilenameValidator::class),
158163
\OCP\Server::get(IAccountManager::class),
159-
false,
164+
$isPublicShare,
160165
!$debugEnabled
161166
)
162167
);

0 commit comments

Comments
 (0)