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:
authorBjoern Schiessle <schiessle@owncloud.com>2013-10-08 17:46:54 +0400
committerBjoern Schiessle <schiessle@owncloud.com>2013-10-08 17:46:54 +0400
commitf700afcb4bf5101c31c1c50672a7652436467f13 (patch)
treec3fd916f7aa51853f2d0b2dd5f21ad9dbb3058ea /lib/connector
parent8ecf88d9f90ecb2091170974044362c8018cf6c1 (diff)
Backport of https://github.com/owncloud/core/pull/5193/
write the part file to the users root folder if the updated file is located in /Shared because we can't create new files in Shared/
Diffstat (limited to 'lib/connector')
-rw-r--r--lib/connector/sabre/directory.php15
-rw-r--r--lib/connector/sabre/file.php7
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index 543bf376d26..96b9cd06d5b 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -50,15 +50,17 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function createFile($name, $data = null) {
- if (!\OC\Files\Filesystem::isCreatable($this->path)) {
- throw new \Sabre_DAV_Exception_Forbidden();
- }
-
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
$info = OC_FileChunking::decodeName($name);
if (empty($info)) {
throw new Sabre_DAV_Exception_NotImplemented();
}
+
+ if (!\OC\Files\Filesystem::isCreatable($this->path) &&
+ !\OC\Files\Filesystem::isUpdatable($this->path . '/' . $info['name'])) {
+ throw new \Sabre_DAV_Exception_Forbidden();
+ }
+
$chunk_handler = new OC_FileChunking($info);
$chunk_handler->store($info['index'], $data);
if ($chunk_handler->isComplete()) {
@@ -67,6 +69,11 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
}
} else {
+
+ if (!\OC\Files\Filesystem::isCreatable($this->path)) {
+ throw new \Sabre_DAV_Exception_Forbidden();
+ }
+
$newPath = $this->path . '/' . $name;
// mark file as partial while uploading (ignored by the scanner)
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php
index 2ddf833f40e..612a36514de 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/connector/sabre/file.php
@@ -53,6 +53,13 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
// mark file as partial while uploading (ignored by the scanner)
$partpath = $this->path . '.part';
+ // if file is located in /Shared we write the part file to the users
+ // root folder because we can't create new files in /shared
+ // we extend the name with a random number to avoid overwriting a existing file
+ if (dirname($partpath) === 'Shared') {
+ $partpath = pathinfo($partpath, PATHINFO_FILENAME) . rand() . '.part';
+ }
+
\OC\Files\Filesystem::file_put_contents($partpath, $data);
//detect aborted upload