summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHélène <pleroma-dev@helene.moe>2022-06-28 20:33:50 +0200
committerHélène <pleroma-dev@helene.moe>2022-06-28 21:33:57 +0200
commit11f9f2ef277937d5558a1cc0a92a60b872f17de0 (patch)
tree4e7d7146ba969ccac0f87fa00e493d33cd7593c6 /lib
parent75f912c63f9a18e37f8ddbd403755b878467435a (diff)
downloadpleroma-11f9f2ef277937d5558a1cc0a92a60b872f17de0.tar.gz
pleroma-11f9f2ef277937d5558a1cc0a92a60b872f17de0.zip
EmojiReactValidator: fix emoji qualification
Tries fully-qualifying emoji when receiving them, by adding the emoji variation sequence to the received reaction emoji. This issue arises when other instance software, such as Misskey, tries reacting with emoji that have unqualified or minimally qualified variants, like a red heart. Pleroma only accepts fully qualified emoji in emoji reactions, and refused those emoji. Now, Pleroma will attempt to properly qualify them first, and reject them if checks still fail.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/emoji_react_validator.ex15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/object_validators/emoji_react_validator.ex b/lib/pleroma/web/activity_pub/object_validators/emoji_react_validator.ex
index ed072b888..bf5166633 100644
--- a/lib/pleroma/web/activity_pub/object_validators/emoji_react_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validators/emoji_react_validator.ex
@@ -49,6 +49,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
defp fix(data) do
data =
data
+ |> fix_emoji_qualification()
|> CommonFixes.fix_actor()
|> CommonFixes.fix_activity_addressing()
@@ -61,6 +62,20 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
end
end
+ defp fix_emoji_qualification(%{"content" => emoji} = data) do
+ # Emoji variation sequence
+ new_emoji = emoji <> "\uFE0F"
+
+ if Pleroma.Emoji.is_unicode_emoji?(new_emoji) do
+ data
+ |> Map.put("content", new_emoji)
+ else
+ data
+ end
+ end
+
+ defp fix_emoji_qualification(data), do: data
+
defp validate_emoji(cng) do
content = get_field(cng, :content)