diff options
author | lambda <pleromagit@rogerbraun.net> | 2018-12-08 09:11:18 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2018-12-08 09:11:18 +0000 |
commit | 8fa5c66eabc9627c0f7de13a27694276e6920822 (patch) | |
tree | bdbc6ec488bbb319dead7cc6018bf8b3130e3e4b /test | |
parent | 4976a8b05f359cd32b37612727f81c89df85d651 (diff) | |
parent | bdc8112e4031a17c39a570bc8fc4bb6b8c35f9aa (diff) | |
download | pleroma-8fa5c66eabc9627c0f7de13a27694276e6920822.tar.gz pleroma-8fa5c66eabc9627c0f7de13a27694276e6920822.zip |
Merge branch 'fix/media-proxy-url-encoded' into 'develop'
Media proxy: fix url encoding
See merge request pleroma/pleroma!521
Diffstat (limited to 'test')
-rw-r--r-- | test/media_proxy_test.exs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/media_proxy_test.exs b/test/media_proxy_test.exs index d71f9f13a..cb455ca79 100644 --- a/test/media_proxy_test.exs +++ b/test/media_proxy_test.exs @@ -1,6 +1,7 @@ defmodule Pleroma.MediaProxyTest do use ExUnit.Case import Pleroma.Web.MediaProxy + alias Pleroma.Web.MediaProxy.MediaProxyController describe "when enabled" do setup do @@ -65,6 +66,14 @@ defmodule Pleroma.MediaProxyTest do assert decode_result(encoded) == url end + test "ensures urls are url-encoded" do + assert decode_result(url("https://pleroma.social/Hello world.jpg")) == + "https://pleroma.social/Hello%20world.jpg" + + assert decode_result(url("https://pleroma.social/Hello%20world.jpg")) == + "https://pleroma.social/Hello%20world.jpg" + end + test "validates signature" do secret_key_base = Pleroma.Config.get([Pleroma.Web.Endpoint, :secret_key_base]) @@ -83,6 +92,34 @@ defmodule Pleroma.MediaProxyTest do assert decode_url(sig, base64) == {:error, :invalid_signature} end + test "filename_matches matches url encoded paths" do + assert MediaProxyController.filename_matches( + true, + "/Hello%20world.jpg", + "http://pleroma.social/Hello world.jpg" + ) == :ok + + assert MediaProxyController.filename_matches( + true, + "/Hello%20world.jpg", + "http://pleroma.social/Hello%20world.jpg" + ) == :ok + end + + test "filename_matches matches non-url encoded paths" do + assert MediaProxyController.filename_matches( + true, + "/Hello world.jpg", + "http://pleroma.social/Hello%20world.jpg" + ) == :ok + + assert MediaProxyController.filename_matches( + true, + "/Hello world.jpg", + "http://pleroma.social/Hello world.jpg" + ) == :ok + end + test "uses the configured base_url" do base_url = Pleroma.Config.get([:media_proxy, :base_url]) |