File tree Expand file tree Collapse file tree
lib/private/Files/Cache/Wrapper
tests/lib/Files/Cache/Wrapper Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -244,6 +244,10 @@ private function formatSearchResults($results) {
244244 * @return array an array of file data
245245 */
246246 public function search ($ pattern ) {
247+ if ($ this ->getGetUnjailedRoot () === '' || $ this ->getGetUnjailedRoot () === '/ ' ) {
248+ return parent ::search ($ pattern );
249+ }
250+
247251 // normalize pattern
248252 $ pattern = $ this ->normalize ($ pattern );
249253
@@ -277,6 +281,10 @@ public function search($pattern) {
277281 * @return array
278282 */
279283 public function searchByMime ($ mimetype ) {
284+ if ($ this ->getGetUnjailedRoot () === '' || $ this ->getGetUnjailedRoot () === '/ ' ) {
285+ return parent ::searchByMime ($ mimetype );
286+ }
287+
280288 $ mimeId = $ this ->mimetypeLoader ->getId ($ mimetype );
281289
282290 $ query = $ this ->getQueryBuilder ();
@@ -304,6 +312,10 @@ public function searchByMime($mimetype) {
304312 }
305313
306314 public function searchQuery (ISearchQuery $ query ) {
315+ if ($ this ->getGetUnjailedRoot () === '' || $ this ->getGetUnjailedRoot () === '/ ' ) {
316+ return parent ::searchQuery ($ query );
317+ }
318+
307319 $ prefixFilter = new SearchComparison (
308320 ISearchComparison::COMPARE_LIKE ,
309321 'path ' ,
Original file line number Diff line number Diff line change @@ -200,4 +200,22 @@ public function testSearchNested() {
200200 $ this ->assertCount (1 , $ result );
201201 $ this ->assertEquals ('asd ' , $ result [0 ]['path ' ]);
202202 }
203+
204+ public function testRootJail () {
205+ $ this ->storage ->getScanner ()->scan ('' );
206+ $ file1 = 'foo ' ;
207+ $ file2 = 'foo/bar ' ;
208+ $ file3 = 'foo/bar/asd ' ;
209+ $ data1 = ['size ' => 100 , 'mtime ' => 50 , 'mimetype ' => 'foo/folder ' ];
210+
211+ $ this ->sourceCache ->put ($ file1 , $ data1 );
212+ $ this ->sourceCache ->put ($ file2 , $ data1 );
213+ $ this ->sourceCache ->put ($ file3 , $ data1 );
214+
215+ $ nested = new \OC \Files \Cache \Wrapper \CacheJail ($ this ->sourceCache , '' );
216+
217+ $ result = $ nested ->search ('%asd% ' );
218+ $ this ->assertCount (1 , $ result );
219+ $ this ->assertEquals ('foo/bar/asd ' , $ result [0 ]['path ' ]);
220+ }
203221}
You can’t perform that action at this time.
0 commit comments