diff options
author | Hélène <pleroma-dev@helene.moe> | 2022-05-18 21:25:10 +0200 |
---|---|---|
committer | Hélène <pleroma-dev@helene.moe> | 2022-05-18 21:25:10 +0200 |
commit | a74ce2d77a53873b3edceeda7287b299c7922a8c (patch) | |
tree | 810b47e729b264d45d0a9f719465cc4558a94fc9 /test | |
parent | 4605efe272016a5ba8ba6e96a9bec9a6e40c1591 (diff) | |
download | pleroma-a74ce2d77a53873b3edceeda7287b299c7922a8c.tar.gz pleroma-a74ce2d77a53873b3edceeda7287b299c7922a8c.zip |
StealEmojiPolicy: fix String rejected_shortcodes
* rejected_shortcodes is defined as a list of strings in the
configuration description. As such, database-based configuration was
led to handle those settings as strings, and not as the actually
expected type, Regex.
* This caused each message passing through this MRF, if a rejected
shortcode was set and the emoji did not exist already on the instance,
to fail federating, as an exception was raised, swiftly caught and
mostly silenced.
* This commit fixes the issue by introducing new behavior: strings are
now handled as perfect matches for an emoji shortcode (meaning that if
the emoji-to-be-pulled's shortcode is in the blacklist, it will be
rejected), while still supporting Regex types as before.
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs b/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs index c537670f2..89d32352f 100644 --- a/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs @@ -60,7 +60,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicyTest do |> File.exists?() end - test "reject shortcode", %{message: message} do + test "reject regex shortcode", %{message: message} do refute "firedfox" in installed() clear_config(:mrf_steal_emoji, @@ -74,6 +74,20 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicyTest do refute "firedfox" in installed() end + test "reject string shortcode", %{message: message} do + refute "firedfox" in installed() + + clear_config(:mrf_steal_emoji, + hosts: ["example.org"], + size_limit: 284_468, + rejected_shortcodes: ["firedfox"] + ) + + assert {:ok, _message} = StealEmojiPolicy.filter(message) + + refute "firedfox" in installed() + end + test "reject if size is above the limit", %{message: message} do refute "firedfox" in installed() |