diff --git a/apps/dav/lib/Upload/ChunkingV2Plugin.php b/apps/dav/lib/Upload/ChunkingV2Plugin.php index 07452dc0593ce..eb8607584d458 100644 --- a/apps/dav/lib/Upload/ChunkingV2Plugin.php +++ b/apps/dav/lib/Upload/ChunkingV2Plugin.php @@ -30,6 +30,7 @@ use OCP\Lock\ILockingProvider; use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\Exception\InsufficientStorage; +use Sabre\DAV\Exception\MethodNotAllowed; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\Exception\PreconditionFailed; use Sabre\DAV\ICollection; @@ -68,14 +69,24 @@ public function __construct(ICacheFactory $cacheFactory) { * @inheritdoc */ public function initialize(Server $server) { - $server->on('afterMethod:MKCOL', [$this, 'afterMkcol']); + $server->on('beforeMethod:GET', $this->beforeGet(...)); $server->on('beforeMethod:PUT', [$this, 'beforePut']); $server->on('beforeMethod:DELETE', [$this, 'beforeDelete']); $server->on('beforeMove', [$this, 'beforeMove'], 90); + $server->on('afterMethod:MKCOL', [$this, 'afterMkcol']); $this->server = $server; } + protected function beforeGet(RequestInterface $request) { + $sourceNode = $this->server->tree->getNodeForPath($request->getPath()); + if (($sourceNode instanceof FutureFile) || ($sourceNode instanceof UploadFile)) { + throw new MethodNotAllowed('Reading intermediate uploads is not allowed'); + } + + return true; + } + /** * @param string $path * @param bool $createIfNotExists diff --git a/apps/dav/lib/Upload/RootCollection.php b/apps/dav/lib/Upload/RootCollection.php index cd7ab7f5e0af4..e8dc4daca22d2 100644 --- a/apps/dav/lib/Upload/RootCollection.php +++ b/apps/dav/lib/Upload/RootCollection.php @@ -26,6 +26,7 @@ public function __construct( private IManager $shareManager, ) { parent::__construct($principalBackend, $principalPrefix); + $this->disableListing = true; } /** diff --git a/apps/dav/lib/Upload/UploadHome.php b/apps/dav/lib/Upload/UploadHome.php index ba1a518bd4b21..b5274cbe6fc57 100644 --- a/apps/dav/lib/Upload/UploadHome.php +++ b/apps/dav/lib/Upload/UploadHome.php @@ -14,6 +14,7 @@ use OCP\Files\NotFoundException; use OCP\IUserSession; use Sabre\DAV\Exception\Forbidden; +use Sabre\DAV\Exception\MethodNotAllowed; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\ICollection; @@ -62,14 +63,7 @@ public function getChild($name): UploadFolder { } public function getChildren(): array { - return array_map(function ($node) { - return new UploadFolder( - $node, - $this->cleanupService, - $this->getStorage(), - $this->uid, - ); - }, $this->impl()->getChildren()); + throw new MethodNotAllowed('Listing members of this collection is disabled'); } public function childExists($name): bool { diff --git a/build/integration/filesdrop_features/filesdrop.feature b/build/integration/filesdrop_features/filesdrop.feature index 52a0399f4b4bd..b606cc53e3485 100644 --- a/build/integration/filesdrop_features/filesdrop.feature +++ b/build/integration/filesdrop_features/filesdrop.feature @@ -199,7 +199,7 @@ Scenario: Files drop allow MKCOL without a nickname And Downloading public folder "Mallory/folder" Then the HTTP status code should be "405" And Downloading public file "Mallory/folder/a.txt" - Then the HTTP status code should be "405" + Then the HTTP status code should be "404" Scenario: Files drop requires nickname if file request is enabled Given user "user0" exists