about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorBen Lubar <ben.lubar@gmail.com>2020-06-08 17:11:42 -0500
committerGitHub <noreply@github.com>2020-06-09 00:11:42 +0200
commitc66403b2579587d8c1448be3ad30dc388d5f29c3 (patch)
tree5d51b35b395792f4a50424399d667239baf0431b /app/lib
parent5e6ec229b2f1fe9f3f41ce2aef9245484fe86192 (diff)
FIX: filters ignore media descriptions (#13837)
* FIX: filters ignore media descriptions

* remove parentheses to make codeclimate happy

* combine the text and run the regular expression only once.

https://github.com/tootsuite/mastodon/pull/13837#discussion_r431752581

* Fix use of “filter” instead of “compact”, fix coding style issues

Co-authored-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/feed_manager.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 13b7aafdf..94872d050 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -246,9 +246,14 @@ class FeedManager
     combined_regex = active_filters.reduce { |memo, obj| Regexp.union(memo, obj) }
     status         = status.reblog if status.reblog?
 
-    !combined_regex.match(Formatter.instance.plaintext(status)).nil? ||
-      (status.spoiler_text.present? && !combined_regex.match(status.spoiler_text).nil?) ||
-      (status.preloadable_poll && !combined_regex.match(status.preloadable_poll.options.join("\n\n")).nil?)
+    combined_text = [
+      Formatter.instance.plaintext(status),
+      status.spoiler_text,
+      status.preloadable_poll ? status.preloadable_poll.options.join("\n\n") : nil,
+      status.media_attachments.map(&:description).join("\n\n"),
+    ].compact.join("\n\n")
+
+    !combined_regex.match(combined_text).nil?
   end
 
   # Adds a status to an account's feed, returning true if a status was