diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-02-12 14:43:34 +0400 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-02-14 15:27:34 +0400 |
commit | eb8b2210cd9ce4bb0209074b36c36addad556fdc (patch) | |
tree | fcd8ea3b4c30f45abe9ac4685de9bf4db970d5ae /apps | |
parent | 118033cac6fe72fed5b54ee06d3e3809c4e4aefa (diff) |
Send correct path on file upload when using public app
Fix issue #7152
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/ajax/upload.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index c45355c6685..e72071e609d 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, ); } } |