about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorAndrea Scarpino <scarpino@kde.org>2017-12-10 19:35:46 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-12-10 19:35:46 +0100
commit6a82939adb823c9a65829c23dc7109a96480befe (patch)
treeb437f700a99faa7c764f28bd414d0fe08c18c045 /app
parent98aa96b8d6800f049e6b185b15a6c215042b8f08 (diff)
Fix account and tag searches with leading/trailing spaces (#5965)
* Strip leading & trailing spaces from account query

* Strip leading & trailing spaces from tag search
Diffstat (limited to 'app')
-rw-r--r--app/models/tag.rb2
-rw-r--r--app/services/account_search_service.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/app/models/tag.rb b/app/models/tag.rb
index 0fa08e157..dc2c8d129 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -23,7 +23,7 @@ class Tag < ApplicationRecord
 
   class << self
     def search_for(term, limit = 5)
-      pattern = sanitize_sql_like(term) + '%'
+      pattern = sanitize_sql_like(term.strip) + '%'
       Tag.where('lower(name) like lower(?)', pattern).order(:name).limit(limit)
     end
   end
diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb
index a289ceac4..3be110665 100644
--- a/app/services/account_search_service.rb
+++ b/app/services/account_search_service.rb
@@ -4,7 +4,7 @@ class AccountSearchService < BaseService
   attr_reader :query, :limit, :options, :account
 
   def call(query, limit, account = nil, options = {})
-    @query   = query
+    @query   = query.strip
     @limit   = limit
     @options = options
     @account = account