summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-01 14:24:42 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:30 +0200
commit51302d58120e9050fb8842cf63cef88620f74203 (patch)
tree9ed61186ea5075e63f8392e78704c3082f3d117c
parentcac83642f2df98497ecedcded1716c28fa676313 (diff)
downloadnextcloud-server-51302d58120e9050fb8842cf63cef88620f74203.tar.gz
nextcloud-server-51302d58120e9050fb8842cf63cef88620f74203.zip
getUidAndFilename() always get uid from path
-rw-r--r--lib/private/encryption/util.php52
1 files changed, 6 insertions, 46 deletions
diff --git a/lib/private/encryption/util.php b/lib/private/encryption/util.php
index 734da741fdd..1183e6622bb 100644
--- a/lib/private/encryption/util.php
+++ b/lib/private/encryption/util.php
@@ -226,7 +226,7 @@ class Util {
}
/**
- * get the owner and the path for the owner
+ * get the owner and the path for the file relative to the owners files folder
*
* @param string $path
* @return array
@@ -240,55 +240,15 @@ class Util {
$uid = $parts[1];
}
if (!$this->userManager->userExists($uid)) {
- throw new \BadMethodCallException('path needs to be relative to the system wide data folder and point to a user specific file');
+ throw new \BadMethodCallException(
+ 'path needs to be relative to the system wide data folder and point to a user specific file'
+ );
}
- $pathInfo = pathinfo($path);
- $partFile = false;
- $parentFolder = false;
- if (array_key_exists('extension', $pathInfo) && $pathInfo['extension'] === 'part') {
- // if the real file exists we check this file
- $filePath = $pathInfo['dirname'] . '/' . $pathInfo['filename'];
- if ($this->view->file_exists($filePath)) {
- $pathToCheck = $pathInfo['dirname'] . '/' . $pathInfo['filename'];
- } else { // otherwise we look for the parent
- $pathToCheck = $pathInfo['dirname'];
- $parentFolder = true;
- }
- $partFile = true;
- } else {
- $pathToCheck = $path;
- }
-
- $pathToCheck = substr($pathToCheck, strlen('/' . $uid));
-
- $this->view->chroot('/' . $uid);
- $owner = $this->view->getOwner($pathToCheck);
-
- // Check that UID is valid
- if (!$this->userManager->userExists($owner)) {
- throw new \BadMethodCallException('path needs to be relative to the system wide data folder and point to a user specific file');
- }
-
- \OC\Files\Filesystem::initMountPoints($owner);
-
- $info = $this->view->getFileInfo($pathToCheck);
- $this->view->chroot('/' . $owner);
- $ownerPath = $this->view->getPath($info->getId());
- $this->view->chroot('/');
+ $ownerPath = implode('/', array_slice($parts, 2));
- if ($parentFolder) {
- $ownerPath = $ownerPath . '/'. $pathInfo['filename'];
- }
-
- if ($partFile) {
- $ownerPath = $ownerPath . '.' . $pathInfo['extension'];
- }
+ return array($uid, \OC\Files\Filesystem::normalizePath($ownerPath));
- return array(
- $owner,
- \OC\Files\Filesystem::normalizePath($ownerPath)
- );
}
/**