diff options
author | David Yip <yipdw@member.fsf.org> | 2017-11-13 11:06:02 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-11-13 11:06:02 -0600 |
commit | 656d54e9451dc99e212513b799a4deb4d1227bf0 (patch) | |
tree | f1269f1ccc89ae14d119ed97a1eeaf121c14b6c7 /app | |
parent | e1b7785788aa3887b06a5b2b10731b4b5d66d7e3 (diff) |
Maintain case-insensitivity when merging multiple matchers (#213)
When given two regexps, Regexp.union preserves the options set (or not set) on each regex; this meant that none of the multiline (m), case-insensitivity (i), or extended syntax (x) options were set. Our regexps are written expecting the m, i, and x options were set on all of them, so we need to make sure that we preserve that behavior.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/glitch/keyword_mute.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/glitch/keyword_mute.rb b/app/models/glitch/keyword_mute.rb index 73de4d4b7..009de1880 100644 --- a/app/models/glitch/keyword_mute.rb +++ b/app/models/glitch/keyword_mute.rb @@ -35,7 +35,7 @@ class Glitch::KeywordMute < ApplicationRecord def initialize(account_id) @account_id = account_id regex_text = Rails.cache.fetch("keyword_mutes:regex:#{account_id}") { regex_text_for_account } - @regex = /#{regex_text}/i + @regex = /#{regex_text}/ end def =~(str) @@ -60,7 +60,7 @@ class Glitch::KeywordMute < ApplicationRecord sb = keyword =~ /\A[[:word:]]/ ? '\b' : '' eb = keyword =~ /[[:word:]]\Z/ ? '\b' : '' - /#{sb}#{Regexp.escape(keyword)}#{eb}/ + /(?mix:#{sb}#{Regexp.escape(keyword)}#{eb})/ end end end |