Skip to content

Commit 5b741f6

Browse files
authored
Merge pull request #59856 from nextcloud/backport/59780/stable31
[stable31] fix(dav): do not list intermediate files
2 parents 4ffb28d + 5eb2070 commit 5b741f6

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

.github/workflows/files-external-smb-kerberos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
with:
5757
persist-credentials: false
5858
repository: nextcloud/user_saml
59+
ref: stable-6
5960
path: apps/user_saml
6061
ref: 'stable-7'
6162

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
@@ -24,6 +24,7 @@ public function __construct(
2424
private IUserSession $userSession,
2525
) {
2626
parent::__construct($principalBackend, $principalPrefix);
27+
$this->disableListing = true;
2728
}
2829

2930
/**

apps/dav/lib/Upload/UploadHome.php

Lines changed: 2 additions & 3 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

@@ -44,9 +45,7 @@ public function getChild($name): UploadFolder {
4445
}
4546

4647
public function getChildren(): array {
47-
return array_map(function ($node) {
48-
return new UploadFolder($node, $this->cleanupService, $this->getStorage());
49-
}, $this->impl()->getChildren());
48+
throw new MethodNotAllowed('Listing members of this collection is disabled');
5049
}
5150

5251
public function childExists($name): bool {

0 commit comments

Comments
 (0)