mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #28235 from nextcloud/jail-search-root-21
[21] dont apply jail search filter is on the root
This commit is contained in:
commit
9353802ba4
2 changed files with 30 additions and 0 deletions
|
|
@ -244,6 +244,10 @@ class CacheJail extends CacheWrapper {
|
|||
* @return array an array of file data
|
||||
*/
|
||||
public function search($pattern) {
|
||||
if ($this->getGetUnjailedRoot() === '' || $this->getGetUnjailedRoot() === '/') {
|
||||
return parent::search($pattern);
|
||||
}
|
||||
|
||||
// normalize pattern
|
||||
$pattern = $this->normalize($pattern);
|
||||
|
||||
|
|
@ -277,6 +281,10 @@ class CacheJail extends CacheWrapper {
|
|||
* @return array
|
||||
*/
|
||||
public function searchByMime($mimetype) {
|
||||
if ($this->getGetUnjailedRoot() === '' || $this->getGetUnjailedRoot() === '/') {
|
||||
return parent::searchByMime($mimetype);
|
||||
}
|
||||
|
||||
$mimeId = $this->mimetypeLoader->getId($mimetype);
|
||||
|
||||
$query = $this->getQueryBuilder();
|
||||
|
|
@ -304,6 +312,10 @@ class CacheJail extends CacheWrapper {
|
|||
}
|
||||
|
||||
public function searchQuery(ISearchQuery $query) {
|
||||
if ($this->getGetUnjailedRoot() === '' || $this->getGetUnjailedRoot() === '/') {
|
||||
return parent::searchQuery($query);
|
||||
}
|
||||
|
||||
$prefixFilter = new SearchComparison(
|
||||
ISearchComparison::COMPARE_LIKE,
|
||||
'path',
|
||||
|
|
|
|||
|
|
@ -200,4 +200,22 @@ class CacheJailTest extends CacheTest {
|
|||
$this->assertCount(1, $result);
|
||||
$this->assertEquals('asd', $result[0]['path']);
|
||||
}
|
||||
|
||||
public function testRootJail() {
|
||||
$this->storage->getScanner()->scan('');
|
||||
$file1 = 'foo';
|
||||
$file2 = 'foo/bar';
|
||||
$file3 = 'foo/bar/asd';
|
||||
$data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'];
|
||||
|
||||
$this->sourceCache->put($file1, $data1);
|
||||
$this->sourceCache->put($file2, $data1);
|
||||
$this->sourceCache->put($file3, $data1);
|
||||
|
||||
$nested = new \OC\Files\Cache\Wrapper\CacheJail($this->sourceCache, '');
|
||||
|
||||
$result = $nested->search('%asd%');
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertEquals('foo/bar/asd', $result[0]['path']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue