Merge pull request 'Remove "default" image description' (#493) from ilja/akkoma:remov...
[akkoma] / test / pleroma / web / activity_pub / activity_pub_test.exs
index 20435d149b98d0371feed57b584d7ab3745026dc..b65575f01421eb684c707c2c9ce562b5df6d1bd0 100644 (file)
@@ -1303,6 +1303,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
       %{test_file: test_file}
     end
 
+    test "strips / from filename", %{test_file: file} do
+      file = %Plug.Upload{file | filename: "../../../../../nested/bad.jpg"}
+      {:ok, %Object{} = object} = ActivityPub.upload(file)
+      [%{"href" => href}] = object.data["url"]
+      assert Regex.match?(~r"/bad.jpg$", href)
+      refute Regex.match?(~r"/nested/", href)
+    end
+
     test "sets a description if given", %{test_file: file} do
       {:ok, %Object{} = object} = ActivityPub.upload(file, description: "a cool file")
       assert object.data["name"] == "a cool file"