Skip to content

Commit

Permalink
Merge pull request #28476 from nextcloud/search-jail-insensitive
Browse files Browse the repository at this point in the history
use case insensitive like when limiting search to jail
  • Loading branch information
PVince81 authored Aug 24, 2021
2 parents 6702c2b + c48f9ff commit e32d293
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/private/Files/Cache/SearchBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
class SearchBuilder {
protected static $searchOperatorMap = [
ISearchComparison::COMPARE_LIKE => 'iLike',
ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE => 'like',
ISearchComparison::COMPARE_EQUAL => 'eq',
ISearchComparison::COMPARE_GREATER_THAN => 'gt',
ISearchComparison::COMPARE_GREATER_THAN_EQUAL => 'gte',
Expand All @@ -48,6 +49,7 @@ class SearchBuilder {

protected static $searchOperatorNegativeMap = [
ISearchComparison::COMPARE_LIKE => 'notLike',
ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE => 'notLike',
ISearchComparison::COMPARE_EQUAL => 'neq',
ISearchComparison::COMPARE_GREATER_THAN => 'lte',
ISearchComparison::COMPARE_GREATER_THAN_EQUAL => 'lt',
Expand Down Expand Up @@ -186,8 +188,8 @@ private function validateComparison(ISearchComparison $operator) {
$comparisons = [
'mimetype' => ['eq', 'like'],
'mtime' => ['eq', 'gt', 'lt', 'gte', 'lte'],
'name' => ['eq', 'like'],
'path' => ['eq', 'like'],
'name' => ['eq', 'like', 'clike'],
'path' => ['eq', 'like', 'clike'],
'size' => ['eq', 'gt', 'lt', 'gte', 'lte'],
'tagname' => ['eq', 'like'],
'favorite' => ['eq'],
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/Wrapper/CacheJail.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public function getQueryFilterForStorage(): ISearchOperator {
new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR,
[
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', $this->getGetUnjailedRoot()),
new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', $this->getGetUnjailedRoot() . '/%'),
new SearchComparison(ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE, 'path', $this->getGetUnjailedRoot() . '/%'),
],
)
]
Expand Down
1 change: 1 addition & 0 deletions lib/public/Files/Search/ISearchComparison.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface ISearchComparison extends ISearchOperator {
public const COMPARE_LESS_THAN = 'lt';
public const COMPARE_LESS_THAN_EQUAL = 'lte';
public const COMPARE_LIKE = 'like';
public const COMPARE_LIKE_CASE_SENSITIVE = 'clike';

/**
* Get the type of comparison, one of the ISearchComparison::COMPARE_* constants
Expand Down

0 comments on commit e32d293

Please sign in to comment.