Skip to content

Commit 2f2cb04

Browse files
authored
Merge pull request #59863 from nextcloud/backport/59780/stable30
[stable30] fix(dav): do not list intermediate files
2 parents 368c803 + 2f04a21 commit 2f2cb04

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
@@ -29,6 +29,7 @@
2929
use OCP\Lock\ILockingProvider;
3030
use Sabre\DAV\Exception\BadRequest;
3131
use Sabre\DAV\Exception\InsufficientStorage;
32+
use Sabre\DAV\Exception\MethodNotAllowed;
3233
use Sabre\DAV\Exception\NotFound;
3334
use Sabre\DAV\Exception\PreconditionFailed;
3435
use Sabre\DAV\ICollection;
@@ -67,14 +68,24 @@ public function __construct(ICacheFactory $cacheFactory) {
6768
* @inheritdoc
6869
*/
6970
public function initialize(Server $server) {
70-
$server->on('afterMethod:MKCOL', [$this, 'afterMkcol']);
71+
$server->on('beforeMethod:GET', $this->beforeGet(...));
7172
$server->on('beforeMethod:PUT', [$this, 'beforePut']);
7273
$server->on('beforeMethod:DELETE', [$this, 'beforeDelete']);
7374
$server->on('beforeMove', [$this, 'beforeMove'], 90);
75+
$server->on('afterMethod:MKCOL', [$this, 'afterMkcol']);
7476

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

80+
protected function beforeGet(RequestInterface $request) {
81+
$sourceNode = $this->server->tree->getNodeForPath($request->getPath());
82+
if (($sourceNode instanceof FutureFile) || ($sourceNode instanceof UploadFile)) {
83+
throw new MethodNotAllowed('Reading intermediate uploads is not allowed');
84+
}
85+
86+
return true;
87+
}
88+
7889
/**
7990
* @param string $path
8091
* @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\ICollection;
1819

1920
class UploadHome implements ICollection {
@@ -43,9 +44,7 @@ public function getChild($name): UploadFolder {
4344
}
4445

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

5150
public function childExists($name): bool {

0 commit comments

Comments
 (0)