From f9090e00e6f6bec903c8df030c4af74ac378fccf Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 5 Jan 2021 13:58:49 -0600 Subject: [PATCH] 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 -- 2.45.2