From fa0d0b602f10a3671ff00151028990c57d8ab447 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 3 Dec 2020 16:17:39 +0100 Subject: [PATCH] Emoji: Also accept regional indicators --- lib/pleroma/emoji.ex | 7 +++++++ test/pleroma/emoji_test.exs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index 201212779..513fb59f8 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -104,6 +104,11 @@ defmodule Pleroma.Emoji do @external_resource "lib/pleroma/emoji-test.txt" + regional_indicators = + Enum.map(127_462..127_487, fn codepoint -> + <> + end) + emojis = @external_resource |> File.read!() @@ -125,6 +130,8 @@ defmodule Pleroma.Emoji do end) |> Enum.uniq() + emojis = emojis ++ regional_indicators + for emoji <- emojis do def is_unicode_emoji?(unquote(emoji)), do: true end diff --git a/test/pleroma/emoji_test.exs b/test/pleroma/emoji_test.exs index 97af25280..9cfd7b46b 100644 --- a/test/pleroma/emoji_test.exs +++ b/test/pleroma/emoji_test.exs @@ -20,6 +20,11 @@ defmodule Pleroma.EmojiTest do assert Emoji.is_unicode_emoji?("🤰") assert Emoji.is_unicode_emoji?("❤️") assert Emoji.is_unicode_emoji?("🏳️‍⚧️") + + # Additionally, we accept regional indicators. + assert Emoji.is_unicode_emoji?("🇵") + assert Emoji.is_unicode_emoji?("🇴") + assert Emoji.is_unicode_emoji?("🇬") end end