From 8fb259e7395d4dd2bdac407b7eca0840ce490a99 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 2 Dec 2020 16:46:19 +0100 Subject: [PATCH] Emoji: Only accept RGI emoji. "recommended for general interchange" --- lib/pleroma/emoji.ex | 5 ++++- test/pleroma/emoji_test.exs | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index 98644f84e..201212779 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -108,7 +108,10 @@ defmodule Pleroma.Emoji do @external_resource |> File.read!() |> String.split("\n") - |> Enum.filter(fn line -> line != "" and not String.starts_with?(line, "#") end) + |> Enum.filter(fn line -> + line != "" and not String.starts_with?(line, "#") and + String.contains?(line, "fully-qualified") + end) |> Enum.map(fn line -> line |> String.split(";", parts: 2) diff --git a/test/pleroma/emoji_test.exs b/test/pleroma/emoji_test.exs index 3070fb19f..97af25280 100644 --- a/test/pleroma/emoji_test.exs +++ b/test/pleroma/emoji_test.exs @@ -11,7 +11,11 @@ defmodule Pleroma.EmojiTest do refute Emoji.is_unicode_emoji?("X") refute Emoji.is_unicode_emoji?("ね") - assert Emoji.is_unicode_emoji?("☂") + # Only accept fully-qualified (RGI) emoji + # See http://www.unicode.org/reports/tr51/ + refute Emoji.is_unicode_emoji?("❤") + refute Emoji.is_unicode_emoji?("☂") + assert Emoji.is_unicode_emoji?("🥺") assert Emoji.is_unicode_emoji?("🤰") assert Emoji.is_unicode_emoji?("❤️") -- 2.45.2