diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2020-04-14 11:48:43 +0200 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2020-04-14 12:52:12 +0200 |
commit | 91ab8118244e2baa0135db4f8c40f8af0bc3dd6b (patch) | |
tree | 242616668f1fad085571b56d01959e884591237a /apps/dav/lib | |
parent | 09bb8ac6e269befda5833556d59d269699ca17b6 (diff) | |
download | nextcloud-server-91ab8118244e2baa0135db4f8c40f8af0bc3dd6b.tar.gz nextcloud-server-91ab8118244e2baa0135db4f8c40f8af0bc3dd6b.zip |
Verify that destination is not a directory.
Otherwise file_put_contents will fail later.
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/Upload/ChunkingPlugin.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php index 35487f61429..5a8d762de80 100644 --- a/apps/dav/lib/Upload/ChunkingPlugin.php +++ b/apps/dav/lib/Upload/ChunkingPlugin.php @@ -23,7 +23,10 @@ namespace OCA\DAV\Upload; +use OCA\DAV\Connector\Sabre\Directory; use Sabre\DAV\Exception\BadRequest; +use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\INode; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; @@ -45,6 +48,9 @@ class ChunkingPlugin extends ServerPlugin { /** * @param string $sourcePath source path * @param string $destination destination path + * @return bool|void + * @throws BadRequest + * @throws NotFound */ public function beforeMove($sourcePath, $destination) { $this->sourceNode = $this->server->tree->getNodeForPath($sourcePath); @@ -53,6 +59,16 @@ class ChunkingPlugin extends ServerPlugin { return; } + try { + /** @var INode $destinationNode */ + $destinationNode = $this->server->tree->getNodeForPath($destination); + if ($destinationNode instanceof Directory) { + throw new BadRequest("The given destination $destination is a directory."); + } + } catch (NotFound $e) { + // If the destination does not exist yet it's not a directory either ;) + } + $this->verifySize(); return $this->performMove($sourcePath, $destination); } |