FIX: Make replace watched words work with wildcard (#13084)

Watched words are always regular expressions, despite watched_words_
_regular_expressions being enabled or not. Internally, wildcard
characters are replaced with a regular expression that matches any non
whitespace character.
This commit is contained in:
Bianca Nenciu
2021-05-18 12:09:47 +03:00
committed by GitHub
parent a21700a444
commit c1dfd76658
5 changed files with 35 additions and 48 deletions
+6
View File
@@ -51,6 +51,12 @@ class WordWatcher
nil # Admin will be alerted via admin_dashboard_data.rb
end
def self.word_matcher_regexps(action)
if words = get_cached_words(action)
words.map { |w, r| [word_to_regexp(w), r] }.to_h
end
end
def self.word_to_regexp(word)
if SiteSetting.watched_words_regular_expressions?
# Strip ruby regexp format if present, we're going to make the whole thing