Skip to content

Commit d07234b

Browse files
susnuxbackportbot[bot]
authored andcommitted
fix(dav): do not read intermediate uploads
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 902bdc9 commit d07234b

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
@@ -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

0 commit comments

Comments
 (0)