Skip to content

Commit

Permalink
Merge pull request #24239 from nextcloud/backport/24203/stable20
Browse files Browse the repository at this point in the history
[stable20] Use regex when searching on single file shares
  • Loading branch information
rullzer authored Nov 20, 2020
2 parents 3839c84 + 37df208 commit 322b0ab
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apps/files_sharing/lib/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,20 @@ private function getOwnerDisplayName() {
public function clear() {
// Not a valid action for Shared Cache
}

public function search($pattern) {
// Do the normal search on the whole storage for non files
if ($this->storage->getItemType() !== 'file') {
return parent::search($pattern);
}

$regex = '/' . str_replace('%', '.*', $pattern) . '/i';

$data = $this->get('');
if (preg_match($regex, $data->getName()) === 1) {
return [$data];
}

return [];
}
}

0 comments on commit 322b0ab

Please sign in to comment.