Skip to content

Commit f569f79

Browse files
authored
Merge pull request #59854 from nextcloud/backport/59780/stable33
[stable33] fix(dav): do not list intermediate files
2 parents 4b7a943 + 0eb5ad7 commit f569f79

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

apps/dav/lib/Upload/ChunkingV2Plugin.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use OCP\Lock\ILockingProvider;
3131
use Sabre\DAV\Exception\BadRequest;
3232
use Sabre\DAV\Exception\InsufficientStorage;
33+
use Sabre\DAV\Exception\MethodNotAllowed;
3334
use Sabre\DAV\Exception\NotFound;
3435
use Sabre\DAV\Exception\PreconditionFailed;
3536
use Sabre\DAV\ICollection;
@@ -68,14 +69,24 @@ public function __construct(ICacheFactory $cacheFactory) {
6869
* @inheritdoc
6970
*/
7071
public function initialize(Server $server) {
71-
$server->on('afterMethod:MKCOL', [$this, 'afterMkcol']);
72+
$server->on('beforeMethod:GET', $this->beforeGet(...));
7273
$server->on('beforeMethod:PUT', [$this, 'beforePut']);
7374
$server->on('beforeMethod:DELETE', [$this, 'beforeDelete']);
7475
$server->on('beforeMove', [$this, 'beforeMove'], 90);
76+
$server->on('afterMethod:MKCOL', [$this, 'afterMkcol']);
7577

7678
$this->server = $server;
7779
}
7880

81+
protected function beforeGet(RequestInterface $request) {
82+
$sourceNode = $this->server->tree->getNodeForPath($request->getPath());
83+
if (($sourceNode instanceof FutureFile) || ($sourceNode instanceof UploadFile)) {
84+
throw new MethodNotAllowed('Reading intermediate uploads is not allowed');
85+
}
86+
87+
return true;
88+
}
89+
7990
/**
8091
* @param string $path
8192
* @param bool $createIfNotExists

apps/dav/lib/Upload/RootCollection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(
2626
private IManager $shareManager,
2727
) {
2828
parent::__construct($principalBackend, $principalPrefix);
29+
$this->disableListing = true;
2930
}
3031

3132
/**

apps/dav/lib/Upload/UploadHome.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCP\Files\NotFoundException;
1515
use OCP\IUserSession;
1616
use Sabre\DAV\Exception\Forbidden;
17+
use Sabre\DAV\Exception\MethodNotAllowed;
1718
use Sabre\DAV\Exception\NotFound;
1819
use Sabre\DAV\ICollection;
1920

@@ -62,14 +63,7 @@ public function getChild($name): UploadFolder {
6263
}
6364

6465
public function getChildren(): array {
65-
return array_map(function ($node) {
66-
return new UploadFolder(
67-
$node,
68-
$this->cleanupService,
69-
$this->getStorage(),
70-
$this->uid,
71-
);
72-
}, $this->impl()->getChildren());
66+
throw new MethodNotAllowed('Listing members of this collection is disabled');
7367
}
7468

7569
public function childExists($name): bool {

build/integration/filesdrop_features/filesdrop.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Scenario: Files drop allow MKCOL without a nickname
199199
And Downloading public folder "Mallory/folder"
200200
Then the HTTP status code should be "405"
201201
And Downloading public file "Mallory/folder/a.txt"
202-
Then the HTTP status code should be "405"
202+
Then the HTTP status code should be "404"
203203

204204
Scenario: Files drop requires nickname if file request is enabled
205205
Given user "user0" exists

0 commit comments

Comments
 (0)