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. This commit contains changes to tests proposed by lanodan. Co-authored-by: Haelwenn <contact+git.pleroma.social@hacktivis.me>
This commit is contained in:
parent
301ce5bc62
commit
388bbc4978
3 changed files with 75 additions and 0 deletions
|
|
@ -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,24 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
|
|||
end
|
||||
end
|
||||
|
||||
defp fix_emoji_qualification(%{"content" => emoji} = data) do
|
||||
# Emoji variation sequence
|
||||
new_emoji = emoji <> "\uFE0F"
|
||||
|
||||
cond do
|
||||
Pleroma.Emoji.is_unicode_emoji?(emoji) ->
|
||||
data
|
||||
|
||||
Pleroma.Emoji.is_unicode_emoji?(new_emoji) ->
|
||||
data |> Map.put("content", new_emoji)
|
||||
|
||||
true ->
|
||||
data
|
||||
end
|
||||
end
|
||||
|
||||
defp fix_emoji_qualification(data), do: data
|
||||
|
||||
defp validate_emoji(cng) do
|
||||
content = get_field(cng, :content)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue