Change: NGルール・NGワードのテキストマッチはHTMLタグを除外する (#623)

This commit is contained in:
KMY(雪あすか) 2024-03-01 12:01:09 +09:00 committed by GitHub
parent bc07ebef3d
commit dc3aabb4f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View file

@ -176,7 +176,7 @@ class Admin::NgRule
end
def detect_keyword?(text, arr)
Admin::NgRule.detect_keyword?(text, arr)
Admin::NgRule.detect_keyword?(text, arr, local: @account.local?)
end
class << self
@ -184,14 +184,15 @@ class Admin::NgRule
text.delete("\r").split("\n")
end
def detect_keyword(text, arr)
def detect_keyword(text, arr, local: true)
arr = string_to_array(arr) if arr.is_a?(String)
text = PlainTextFormatter.new(text, false).to_s unless local
arr.detect { |word| include?(text, word) ? word : nil }
end
def detect_keyword?(text, arr)
detect_keyword(text, arr).present?
def detect_keyword?(text, arr, local: true)
detect_keyword(text, arr, local: local).present?
end
def include?(text, word)