Skip to content

Commit 2aa079b

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

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

apps/dav/lib/Upload/ChunkingPlugin.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
use OCA\DAV\Connector\Sabre\Directory;
2929
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
3030
use Sabre\DAV\Exception\BadRequest;
31+
use Sabre\DAV\Exception\MethodNotAllowed;
3132
use Sabre\DAV\Exception\NotFound;
3233
use Sabre\DAV\INode;
3334
use Sabre\DAV\Server;
3435
use Sabre\DAV\ServerPlugin;
36+
use Sabre\HTTP\RequestInterface;
3537

3638
class ChunkingPlugin extends ServerPlugin {
3739

@@ -45,9 +47,22 @@ class ChunkingPlugin extends ServerPlugin {
4547
*/
4648
public function initialize(Server $server) {
4749
$server->on('beforeMove', [$this, 'beforeMove']);
50+
$server->on('beforeMethod:GET', [$this, 'beforeGet']);
4851
$this->server = $server;
4952
}
5053

54+
/**
55+
* @param RequestInterface $request
56+
*/
57+
public function beforeGet($request) {
58+
$sourceNode = $this->server->tree->getNodeForPath($request->getPath());
59+
if (($sourceNode instanceof FutureFile) || ($sourceNode instanceof UploadFile)) {
60+
throw new MethodNotAllowed('Reading intermediate uploads is not allowed');
61+
}
62+
63+
return true;
64+
}
65+
5166
/**
5267
* @param string $sourcePath source path
5368
* @param string $destination destination path

0 commit comments

Comments
 (0)