[Pkg-owncloud-commits] [owncloud] 99/145: Send correct path on file upload when using public app

David Prévot taffit at moszumanska.debian.org
Wed Feb 26 16:27:45 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit eb8b2210cd9ce4bb0209074b36c36addad556fdc
Author: Joas Schilling <nickvergessen at gmx.de>
Date:   Wed Feb 12 11:43:34 2014 +0100

    Send correct path on file upload when using public app
    
    Fix issue #7152
---
 apps/files/ajax/upload.php | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index c45355c..e72071e 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -21,6 +21,7 @@ if (empty($_POST['dirToken'])) {
 } else {
 	// return only read permissions for public upload
 	$allowedPermissions = OCP\PERMISSION_READ;
+	$public_directory = !empty($_POST['subdir']) ? $_POST['subdir'] : '/';
 
 	$linkItem = OCP\Share::getShareByToken($_POST['dirToken']);
 	if ($linkItem === false) {
@@ -44,7 +45,7 @@ if (empty($_POST['dirToken'])) {
 		$dir = sprintf(
 			"/%s/%s",
 			$path,
-			isset($_POST['subdir']) ? $_POST['subdir'] : ''
+			$public_directory
 		);
 
 		if (!$dir || empty($dir) || $dir === false) {
@@ -111,7 +112,14 @@ if (strpos($dir, '..') === false) {
 		} else {
 			$target = \OC\Files\Filesystem::normalizePath(stripslashes($dir).'/'.$files['name'][$i]);
 		}
-		
+
+		$directory = \OC\Files\Filesystem::normalizePath(stripslashes($dir));
+		if (isset($public_directory)) {
+			// If we are uploading from the public app,
+			// we want to send the relative path in the ajax request.
+			$directory = $public_directory;
+		}
+
 		if ( ! \OC\Files\Filesystem::file_exists($target)
 			|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
 		) {
@@ -138,7 +146,7 @@ if (strpos($dir, '..') === false) {
 							'uploadMaxFilesize' => $maxUploadFileSize,
 							'maxHumanFilesize' => $maxHumanFileSize,
 							'permissions' => $meta['permissions'] & $allowedPermissions,
-							'directory' => \OC\Files\Filesystem::normalizePath(stripslashes($dir)),
+							'directory' => $directory,
 						);
 					}
 
@@ -166,7 +174,7 @@ if (strpos($dir, '..') === false) {
 					'uploadMaxFilesize' => $maxUploadFileSize,
 					'maxHumanFilesize' => $maxHumanFileSize,
 					'permissions' => $meta['permissions'] & $allowedPermissions,
-					'directory' => \OC\Files\Filesystem::normalizePath(stripslashes($dir)),
+					'directory' => $directory,
 				);
 			}
 		}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list