From d62500cb56f5108df4f6f8822b93a9136c052d44 Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 18 Aug 2016 13:14:31 +0200 Subject: [PATCH] check search input string [fixes SCI-346] --- app/controllers/search_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index ead93a8ec..6215888a3 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -49,6 +49,12 @@ class SearchController < ApplicationController @search_category = @search_category.to_sym @search_page = params[:page].to_i || 1 @display_query = @search_query + + if @search_query.length < MIN_QUERY_CHARS + flash[:error] = t'search.index.error.query_length', n: MIN_QUERY_CHARS + return redirect_to :back + end + # splits the search query to validate all entries @splited_query = @search_query.split @@ -64,9 +70,7 @@ class SearchController < ApplicationController @search_query = @splited_query.join(' ') end - if @search_page < 1 - @search_page = 1 - end + @search_page = 1 if @search_page < 1 end # Initialize markdown parser