Skip to content

Commit bcfa3bd

Browse files
committed
fix(dav): do not read intermediate uploads
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent e1049a8 commit bcfa3bd

1 file changed

Lines changed: 12 additions & 1 deletion

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

0 commit comments

Comments
 (0)