diff options
author | David Yip <yipdw@member.fsf.org> | 2018-02-10 10:32:14 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2018-02-10 10:36:16 -0600 |
commit | f1f67c46c5b369476090429a46dbc646d772ae25 (patch) | |
tree | 2150d21584c788f9e69dd930dd5ec531d6ab6c41 /app | |
parent | 9105b0c95428e3bbecd6f8ad106508095eed5643 (diff) |
Use Html2Text to generate plaintext for keyword mutes. #236.
This allows us to match URLs inside link hrefs.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/glitch/keyword_mute_helper.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/app/models/glitch/keyword_mute_helper.rb b/app/models/glitch/keyword_mute_helper.rb index 1b8c64e4e..6d067947f 100644 --- a/app/models/glitch/keyword_mute_helper.rb +++ b/app/models/glitch/keyword_mute_helper.rb @@ -1,16 +1,12 @@ -require 'htmlentities' +require 'html2text' class Glitch::KeywordMuteHelper - include ActionView::Helpers::SanitizeHelper - attr_reader :text_matcher attr_reader :tag_matcher - attr_reader :entity_decoder def initialize(receiver_id) @text_matcher = Glitch::KeywordMute.text_matcher_for(receiver_id) @tag_matcher = Glitch::KeywordMute.tag_matcher_for(receiver_id) - @entity_decoder = HTMLEntities.new end def matches?(status) @@ -26,6 +22,6 @@ class Glitch::KeywordMuteHelper end def prepare_text(text) - entity_decoder.decode(strip_tags(text)).tap { |x| puts x } + Html2Text.convert(text) end end |