commit: a9bc652ab9f4880566a823d3d67fe0247f7954f4
parent f930e83fa2a7e2184ca6bd09773d81568e7c755c
Author: rinpatch <rin@patch.cx>
Date: Fri, 19 Mar 2021 08:52:12 +0000
Merge branch 'mediaproxy-decode' into 'develop'
Simple way to decode mediaproxy URLs
See merge request pleroma/pleroma!3364
Diffstat:
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/pleroma/web/media_proxy.ex b/lib/pleroma/web/media_proxy.ex
@@ -121,6 +121,11 @@ defmodule Pleroma.Web.MediaProxy do
end
end
+ def decode_url(encoded) do
+ [_, "proxy", sig, base64 | _] = URI.parse(encoded).path |> String.split("/")
+ decode_url(sig, base64)
+ end
+
defp signed_url(url) do
:crypto.hmac(:sha, Config.get([Web.Endpoint, :secret_key_base]), url)
end
diff --git a/test/pleroma/web/media_proxy_test.exs b/test/pleroma/web/media_proxy_test.exs
@@ -11,8 +11,7 @@ defmodule Pleroma.Web.MediaProxyTest do
alias Pleroma.Web.MediaProxy
defp decode_result(encoded) do
- [_, "proxy", sig, base64 | _] = URI.parse(encoded).path |> String.split("/")
- {:ok, decoded} = MediaProxy.decode_url(sig, base64)
+ {:ok, decoded} = MediaProxy.decode_url(encoded)
decoded
end