diff options
author | Björn Schießle <schiessle@owncloud.com> | 2014-01-23 01:09:34 -0800 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2014-01-23 01:09:34 -0800 |
commit | 0daabe5b6a2f96e8b754c2414bb83d00277a307a (patch) | |
tree | 021085e13817db79dea85845e7af04579b8f6080 /apps | |
parent | 4474421ada2a4b5642f1a081d6491d7858b3b9b0 (diff) | |
parent | b489d6b0af1577031de017b5b01bd76ed5c871e0 (diff) | |
download | nextcloud-server-0daabe5b6a2f96e8b754c2414bb83d00277a307a.tar.gz nextcloud-server-0daabe5b6a2f96e8b754c2414bb83d00277a307a.zip |
Merge pull request #6898 from owncloud/encryption_infinite_loop
[encryption] infinite loop on sharing
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_encryption/lib/util.php | 52 | ||||
-rw-r--r-- | apps/files_sharing/lib/cache.php | 23 |
2 files changed, 30 insertions, 45 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 8a5dfabeec1..8816d4d649a 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -2,9 +2,10 @@ /** * ownCloud * - * @author Sam Tuke, Frank Karlitschek + * @author Sam Tuke, Frank Karlitschek, Bjoern Schiessle * @copyright 2012 Sam Tuke <samtuke@owncloud.com>, - * Frank Karlitschek <frank@owncloud.org> + * Frank Karlitschek <frank@owncloud.org>, + * Bjoern Schiessle <schiessle@owncloud.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -1360,59 +1361,32 @@ class Util { } } - /** * @brief go recursively through a dir and collect all files and sub files. * @param string $dir relative to the users files folder * @return array with list of files relative to the users files folder */ public function getAllFiles($dir) { - $result = array(); + $dirList = array($dir); - $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath( - $this->userFilesDir . '/' . $dir)); - - // handling for re shared folders - $pathSplit = explode('/', $dir); - - foreach ($content as $c) { - - $sharedPart = $pathSplit[sizeof($pathSplit) - 1]; - $targetPathSplit = array_reverse(explode('/', $c['path'])); - - $path = ''; - - // rebuild path - foreach ($targetPathSplit as $pathPart) { - - if ($pathPart !== $sharedPart) { - - $path = '/' . $pathPart . $path; + while ($dirList) { + $dir = array_pop($dirList); + $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath( + $this->userFilesDir . '/' . $dir)); + foreach ($content as $c) { + $usersPath = isset($c['usersPath']) ? $c['usersPath'] : $c['path']; + if ($c['type'] === 'dir') { + $dirList[] = substr($usersPath, strlen("files")); } else { - - break; - + $result[] = substr($usersPath, strlen("files")); } - } - $path = $dir . $path; - - if ($c['type'] === 'dir') { - - $result = array_merge($result, $this->getAllFiles($path)); - - } else { - - $result[] = $path; - - } } return $result; - } /** diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 90440d08f4e..425d51113b1 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -127,7 +127,18 @@ class Shared_Cache extends Cache { return $files; } else { if ($cache = $this->getSourceCache($folder)) { - return $cache->getFolderContents($this->files[$folder]); + $sourceFolderContent = $cache->getFolderContents($this->files[$folder]); + foreach ($sourceFolderContent as $key => $c) { + $ownerPathParts = explode('/', \OC_Filesystem::normalizePath($c['path'])); + $userPathParts = explode('/', \OC_Filesystem::normalizePath($folder)); + $usersPath = 'files/Shared/'.$userPathParts[1]; + foreach (array_slice($ownerPathParts, 3) as $part) { + $usersPath .= '/'.$part; + } + $sourceFolderContent[$key]['usersPath'] = $usersPath; + } + + return $sourceFolderContent; } } return false; @@ -260,7 +271,7 @@ class Shared_Cache extends Cache { return $this->searchWithWhere($where, $value); } - + /** * The maximum number of placeholders that can be used in an SQL query. * Value MUST be <= 1000 for oracle: @@ -268,7 +279,7 @@ class Shared_Cache extends Cache { * FIXME we should get this from doctrine as other DBs allow a lot more placeholders */ const MAX_SQL_CHUNK_SIZE = 1000; - + /** * search for files with a custom where clause and value * the $wherevalue will be array_merge()d with the file id chunks @@ -282,16 +293,16 @@ class Shared_Cache extends Cache { $ids = $this->getAll(); $files = array(); - + // divide into chunks $chunks = array_chunk($ids, $chunksize); - + foreach ($chunks as $chunk) { $placeholders = join(',', array_fill(0, count($chunk), '?')); $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag` FROM `*PREFIX*filecache` WHERE ' . $sqlwhere . ' `fileid` IN (' . $placeholders . ')'; - + $stmt = \OC_DB::prepare($sql); $result = $stmt->execute(array_merge(array($wherevalue), $chunk)); |