Add test to validate URLs to custom emojis are properly encoded
authorMark Felder <feld@feld.me>
Tue, 5 Jan 2021 19:58:49 +0000 (13:58 -0600)
committerMark Felder <feld@feld.me>
Tue, 5 Jan 2021 19:58:49 +0000 (13:58 -0600)
test/pleroma/web/activity_pub/transmogrifier_test.exs

index 66ea7664aff340a9135158e9cc9be64e853ded31..aa32ebaab26a8077da0ac954d480d2b28f498bb6 100644 (file)
@@ -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