From 3f760069b3b43e21994f445102d926a254f4c7b9 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 21 May 2017 13:52:56 -0500 Subject: [PATCH 1/2] dmails: fix case sensitivity bug in dmail title search. --- app/models/dmail.rb | 2 +- test/unit/dmail_test.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/dmail.rb b/app/models/dmail.rb index 688e50c69..06e84ae3f 100644 --- a/app/models/dmail.rb +++ b/app/models/dmail.rb @@ -104,7 +104,7 @@ class Dmail < ActiveRecord::Base def title_matches(query) query = "*#{query}*" unless query =~ /\*/ - where("lower(dmails.title) LIKE ?", query.to_escaped_for_sql_like) + where("lower(dmails.title) LIKE ?", query.mb_chars.downcase.to_escaped_for_sql_like) end def search_message(query) diff --git a/test/unit/dmail_test.rb b/test/unit/dmail_test.rb index ec89c655c..b97b4aacf 100644 --- a/test/unit/dmail_test.rb +++ b/test/unit/dmail_test.rb @@ -78,6 +78,9 @@ class DmailTest < ActiveSupport::TestCase matches = Dmail.search(title_matches: "x") assert_equal([dmail.id], matches.map(&:id)) + matches = Dmail.search(title_matches: "X") + assert_equal([dmail.id], matches.map(&:id)) + matches = Dmail.search(message_matches: "xxx") assert_equal([dmail.id], matches.map(&:id)) From c31d11b09506a86121e58cecc3851757a8a9b9d6 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 21 May 2017 20:13:43 -0500 Subject: [PATCH 2/2] bans: fix case sensitivity bug in ban reason search. --- app/models/ban.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/ban.rb b/app/models/ban.rb index 289abf564..7f8080c2a 100644 --- a/app/models/ban.rb +++ b/app/models/ban.rb @@ -19,7 +19,7 @@ class Ban < ActiveRecord::Base def self.reason_matches(query) if query =~ /\*/ - where("lower(bans.reason) LIKE ?", query.to_escaped_for_sql_like) + where("lower(bans.reason) LIKE ?", query.mb_chars.downcase.to_escaped_for_sql_like) else where("bans.reason @@ plainto_tsquery(?)", query) end