diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-09-22 01:23:18 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-09-22 01:24:12 +0200 |
commit | a1d4eb1f956148fe9002dd17bdfef3bd66063bf0 (patch) | |
tree | e0fb4b9afb432aa6cf997bda3b91bf2c818c4ad2 /lib/files | |
parent | 5b95e7aa0f0487d7ddb07588c71d25cd973c2bb6 (diff) | |
download | nextcloud-server-a1d4eb1f956148fe9002dd17bdfef3bd66063bf0.tar.gz nextcloud-server-a1d4eb1f956148fe9002dd17bdfef3bd66063bf0.zip |
files: when filtering search results, ensure results are children of the fakeroot not just path starting the same
Diffstat (limited to 'lib/files')
-rw-r--r-- | lib/files/view.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/files/view.php b/lib/files/view.php index 968b755a661..aa08a5f7cc9 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -500,7 +500,7 @@ class View { } else { if ($this->is_dir($path1) && ($dh = $this->opendir($path1))) { $result = $this->mkdir($path2); - if(is_resource($dh)) { + if (is_resource($dh)) { while (($file = readdir($dh)) !== false) { if (!Filesystem::isIgnoredDir($file)) { $result = $this->copy($path1 . '/' . $file, $path2 . '/' . $file); @@ -975,7 +975,7 @@ class View { /** * search for files by mimetype * - * @param string $query + * @param string $mimetype * @return array */ public function searchByMime($mimetype) { @@ -998,7 +998,7 @@ class View { $results = $cache->$method($query); foreach ($results as $result) { - if (substr($mountPoint . $result['path'], 0, $rootLength) === $this->fakeRoot) { + if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') { $result['path'] = substr($mountPoint . $result['path'], $rootLength); $files[] = $result; } @@ -1012,9 +1012,11 @@ class View { $relativeMountPoint = substr($mountPoint, $rootLength); $results = $cache->$method($query); - foreach ($results as $result) { - $result['path'] = $relativeMountPoint . $result['path']; - $files[] = $result; + if ($results) { + foreach ($results as $result) { + $result['path'] = $relativeMountPoint . $result['path']; + $files[] = $result; + } } } } |