Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-14 21:08:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-14 21:08:31 +0300
commit92f95ccac81911d1fcc32e999a7f1ce04624a56c (patch)
treead207e86b7858ae93a085fbdc04155f5cd469620 /app/services/search_service.rb
parent85e494935a8726dc98bb19ffa584488420e5011e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/search_service.rb')
-rw-r--r--app/services/search_service.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/services/search_service.rb b/app/services/search_service.rb
index 91c0f9ba104..fe5e823b56c 100644
--- a/app/services/search_service.rb
+++ b/app/services/search_service.rb
@@ -3,6 +3,9 @@
class SearchService
include Gitlab::Allowable
+ SEARCH_TERM_LIMIT = 64
+ SEARCH_CHAR_LIMIT = 4096
+
def initialize(current_user, params = {})
@current_user = current_user
@params = params.dup
@@ -42,6 +45,14 @@ class SearchService
@show_snippets = params[:snippets] == 'true'
end
+ def valid_query_length?
+ params[:search].length <= SEARCH_CHAR_LIMIT
+ end
+
+ def valid_terms_count?
+ params[:search].split.count { |word| word.length >= 3 } <= SEARCH_TERM_LIMIT
+ end
+
delegate :scope, to: :search_service
def search_results