Skip to content

Commit 38f8423

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. Signed-off-by: Salvatore Martire <[email protected]>
1 parent c5ad20d commit 38f8423

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

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
@@ -71,8 +71,13 @@ public function createServer(
7171
Plugin $authPlugin,
7272
callable $viewCallBack,
7373
): Server {
74+
// /public.php/webdav/ shows the files in the share in the root itself
75+
// and not under /public.php/webdav/files/{token} so we should keep
76+
// compatibility for that.
77+
$needsSharesInRoot = $baseUri === '/public.php/webdav/';
78+
$useCollection = $isPublicShare && !$needsSharesInRoot;
7479
$debugEnabled = $this->config->getSystemValue('debug', false);
75-
[$tree, $rootCollection] = $this->getTree($isPublicShare);
80+
[$tree, $rootCollection] = $this->getTree($useCollection);
7681
$server = new Server($tree);
7782
// Set URL explicitly due to reverse-proxy situations
7883
$server->httpRequest->setUrl($requestUri);
@@ -121,8 +126,8 @@ public function createServer(
121126
}
122127

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

@@ -157,7 +162,7 @@ public function createServer(
157162
$this->userSession,
158163
\OCP\Server::get(IFilenameValidator::class),
159164
\OCP\Server::get(IAccountManager::class),
160-
false,
165+
$isPublicShare,
161166
!$debugEnabled
162167
)
163168
);

0 commit comments

Comments
 (0)