From b93b066a425fae11d304ee59f8d745e1251005a9 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind1991@gmail.com>
Date: Sun, 31 Jul 2011 15:35:37 +0200
Subject: [PATCH] fix search results having files from other users

---
 lib/filesystem.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/filesystem.php b/lib/filesystem.php
index 6022aa585b..a688c9c2b0 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -573,14 +573,17 @@ class OC_Filesystem{
 	
 	static public function search($query){
 		$files=array();
-		$fakeRootLength=strlen(self::$fakeRoot);
+		$fakeRoot=self::$fakeRoot;
+		$fakeRootLength=strlen($fakeRoot);
 		foreach(self::$storages as $mountpoint=>$storage){
 			$results=$storage->search($query);
 			if(is_array($results)){
 				foreach($results as $result){
 					$file=str_replace('//','/',$mountpoint.$result);
-					$file=substr($file,$fakeRootLength);
-					$files[]=$file;
+					if(substr($file,0,$fakeRootLength)==$fakeRoot){
+						$file=substr($file,$fakeRootLength);
+						$files[]=$file;
+					}
 				}
 			}
 		}
-- 
GitLab