Skip to content

Commit e7ef9a9

Browse files
authored
Merge pull request #59943 from nextcloud/backport/59864/stable28
[stable28] fix(dav): do not list intermediate files
2 parents db156d7 + 7005747 commit e7ef9a9

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

apps/dav/lib/Upload/ChunkingV2Plugin.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use OCP\Lock\ILockingProvider;
4747
use Sabre\DAV\Exception\BadRequest;
4848
use Sabre\DAV\Exception\InsufficientStorage;
49+
use Sabre\DAV\Exception\MethodNotAllowed;
4950
use Sabre\DAV\Exception\NotFound;
5051
use Sabre\DAV\Exception\PreconditionFailed;
5152
use Sabre\DAV\ICollection;
@@ -84,14 +85,24 @@ public function __construct(ICacheFactory $cacheFactory) {
8485
* @inheritdoc
8586
*/
8687
public function initialize(Server $server) {
87-
$server->on('afterMethod:MKCOL', [$this, 'afterMkcol']);
88+
$server->on('beforeMethod:GET', [$this, 'beforeGet']);
8889
$server->on('beforeMethod:PUT', [$this, 'beforePut']);
8990
$server->on('beforeMethod:DELETE', [$this, 'beforeDelete']);
9091
$server->on('beforeMove', [$this, 'beforeMove'], 90);
92+
$server->on('afterMethod:MKCOL', [$this, 'afterMkcol']);
9193

9294
$this->server = $server;
9395
}
9496

97+
public function beforeGet(RequestInterface $request) {
98+
$sourceNode = $this->server->tree->getNodeForPath($request->getPath());
99+
if (($sourceNode instanceof FutureFile) || ($sourceNode instanceof UploadFile)) {
100+
throw new MethodNotAllowed('Reading intermediate uploads is not allowed');
101+
}
102+
103+
return true;
104+
}
105+
95106
/**
96107
* @param string $path
97108
* @param bool $createIfNotExists

apps/dav/lib/Upload/RootCollection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function __construct(PrincipalBackend\BackendInterface $principalBackend,
3939
CleanupService $cleanupService) {
4040
parent::__construct($principalBackend, $principalPrefix);
4141
$this->cleanupService = $cleanupService;
42+
$this->disableListing = true;
4243
}
4344

4445
/**

apps/dav/lib/Upload/UploadHome.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use OC\Files\View;
3030
use OCA\DAV\Connector\Sabre\Directory;
3131
use Sabre\DAV\Exception\Forbidden;
32+
use Sabre\DAV\Exception\MethodNotAllowed;
3233
use Sabre\DAV\ICollection;
3334

3435
class UploadHome implements ICollection {
@@ -58,9 +59,7 @@ public function getChild($name): UploadFolder {
5859
}
5960

6061
public function getChildren(): array {
61-
return array_map(function ($node) {
62-
return new UploadFolder($node, $this->cleanupService, $this->getStorage());
63-
}, $this->impl()->getChildren());
62+
throw new MethodNotAllowed('Listing members of this collection is disabled');
6463
}
6564

6665
public function childExists($name): bool {

0 commit comments

Comments
 (0)