Merge branch 'mediaproxy-decode' into 'develop'

Simple way to decode mediaproxy URLs

See merge request pleroma/pleroma!3364
This commit is contained in:
rinpatch 2021-03-19 08:52:12 +00:00
commit a9bc652ab9
2 changed files with 6 additions and 2 deletions

View file

@ -121,6 +121,11 @@ def decode_url(sig, url) 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

View file

@ -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