From 64116f63d99a1eab9b697fc7a103e72dc80a095c Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 5 Jan 2021 12:25:30 -0600 Subject: [PATCH 1/3] URI.encode custom emojis --- lib/pleroma/web/activity_pub/transmogrifier.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 565d32433..5499f8a08 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -919,7 +919,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do defp build_emoji_tag({name, url}) do %{ - "icon" => %{"url" => url, "type" => "Image"}, + "icon" => %{"url" => "#{URI.encode(url)}", "type" => "Image"}, "name" => ":" <> name <> ":", "type" => "Emoji", "updated" => "1970-01-01T00:00:00Z", From 8864ac65c693eb19a36a6e0116abc13bcfe70ddb Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 5 Jan 2021 13:25:14 -0600 Subject: [PATCH 2/3] Add dinosaur gif from https://gifs.cc "Our animations are free to be used to enhance your website." --- config/emoji.txt | 1 + priv/static/emoji/dino walking.gif | Bin 0 -> 11213 bytes 2 files changed, 1 insertion(+) create mode 100644 priv/static/emoji/dino walking.gif diff --git a/config/emoji.txt b/config/emoji.txt index 200768ad1..52b714ee5 100644 --- a/config/emoji.txt +++ b/config/emoji.txt @@ -1,2 +1,3 @@ firefox, /emoji/Firefox.gif, Gif,Fun blank, /emoji/blank.png, Fun +dinosaur, /emoji/dino walking.gif, Gif diff --git a/priv/static/emoji/dino walking.gif b/priv/static/emoji/dino walking.gif new file mode 100644 index 0000000000000000000000000000000000000000..694a541e7f694393f6730e18d807d5a48b667a21 GIT binary patch literal 11213 zcmb7~XH*mU!|#7HnMo!ENF#v|Aqg$?1Q9_LCjk@?H6ki1YACv_qQ;JjItf)_HDE(T z4Mjy|m1akF0xH;JSwv;spseEBV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z(F0*iZ}395=ms0J`=nnnf|P3kIMC7wGnsQw+Cx|+K~%AOJP+5*CufjIz?!Q0sJPZ^ zc=~~X=1DMBo4sQC(lKJ!a>#?!!*|ClfcB&$s77oU=Z}9f)u#UJuo|h`wW{Y{mJW`e z>8VwLJU>tTk?$6u`}wQ!c8OV{;Ip3cfxNX6iM36eQ_Jp77YbIt784B?@N~* O^Y9wEr$_=o#Qy?@3b;D} literal 0 HcmV?d00001 From f9090e00e6f6bec903c8df030c4af74ac378fccf Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 5 Jan 2021 13:58:49 -0600 Subject: [PATCH 3/3] Add test to validate URLs to custom emojis are properly encoded --- .../web/activity_pub/transmogrifier_test.exs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs index 66ea7664a..aa32ebaab 100644 --- a/test/pleroma/web/activity_pub/transmogrifier_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs @@ -281,6 +281,21 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do {:ok, _modified} = Transmogrifier.prepare_outgoing(activity.data) end + + test "custom emoji urls are URI encoded" do + # :dinosaur: filename has a space -> dino walking.gif + user = insert(:user) + + {:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"}) + + {:ok, prepared} = Transmogrifier.prepare_outgoing(activity.data) + + assert length(prepared["object"]["tag"]) == 1 + + url = prepared["object"]["tag"] |> List.first() |> Map.get("icon") |> Map.get("url") + + assert url == "http://localhost:4001/emoji/dino%20walking.gif" + end end describe "user upgrade" do