From 392c6b6832edfc37a2956ef3a77fab6020a7a746 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= <jfd@butonic.de>
Date: Wed, 7 Aug 2013 18:18:40 +0200
Subject: [PATCH] return fixed path, skip shared files outside of 'files'

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

diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 6386f1d2c6..a440246448 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -254,9 +254,12 @@ class Shared_Cache extends Cache {
 			$result = \OC_DB::executeAudited($sql, array_merge(array($pattern), $chunk));
 			
 			while ($row = $result->fetchRow()) {
-				$row['mimetype'] = $this->getMimetype($row['mimetype']);
-				$row['mimepart'] = $this->getMimetype($row['mimepart']);
-				$files[] = $row;
+				if (substr($row['path'], 0, 6)==='files/') {
+					$row['path'] = substr($row['path'],6); // remove 'files/' from path as it's relative to '/Shared'
+					$row['mimetype'] = $this->getMimetype($row['mimetype']);
+					$row['mimepart'] = $this->getMimetype($row['mimepart']);
+					$files[] = $row;
+				} // else skip results out of the files folder
 			}
 		}
 		return $files;
-- 
GitLab