Merge pull request #59944 from nextcloud/backport/59864/stable27

[stable27] fix(dav): do not list intermediate files
This commit is contained in:
Stephan Orbaugh 2026-04-28 09:14:05 +02:00 committed by GitHub
commit 6e5e393f0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 4 deletions

View file

@ -46,6 +46,7 @@ use OCP\IConfig;
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;
@ -84,14 +85,24 @@ class ChunkingV2Plugin extends ServerPlugin {
* @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;
}
public 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

View file

@ -39,6 +39,7 @@ class RootCollection extends AbstractPrincipalCollection {
CleanupService $cleanupService) {
parent::__construct($principalBackend, $principalPrefix);
$this->cleanupService = $cleanupService;
$this->disableListing = true;
}
/**

View file

@ -29,6 +29,7 @@ use OC\Files\Filesystem;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Directory;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\MethodNotAllowed;
use Sabre\DAV\ICollection;
class UploadHome implements ICollection {
@ -58,9 +59,7 @@ class UploadHome implements ICollection {
}
public function getChildren(): array {
return array_map(function ($node) {
return new UploadFolder($node, $this->cleanupService, $this->getStorage());
}, $this->impl()->getChildren());
throw new MethodNotAllowed('Listing members of this collection is disabled');
}
public function childExists($name): bool {