Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2020-04-14 12:48:43 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2020-04-14 13:52:12 +0300
commit91ab8118244e2baa0135db4f8c40f8af0bc3dd6b (patch)
tree242616668f1fad085571b56d01959e884591237a /apps/dav/lib
parent09bb8ac6e269befda5833556d59d269699ca17b6 (diff)
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.php16
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);
}