Merge branch 'fix-media-proxy-filename' into 'develop'

media_proxy: use path only to retrieve filename

See merge request pleroma/pleroma!450
This commit is contained in:
lambda 2018-11-14 18:17:10 +00:00
commit cc45797f4e
2 changed files with 2 additions and 2 deletions

View file

@ -30,7 +30,7 @@ def remote(conn, params = %{"sig" => sig, "url" => url}) do
with true <- Keyword.get(config, :enabled, false),
{:ok, url} <- Pleroma.Web.MediaProxy.decode_url(sig, url),
filename <- Path.basename(url),
filename <- Path.basename(URI.parse(url).path),
true <-
if(Map.get(params, "filename"),
do: filename == Path.basename(conn.request_path),

View file

@ -15,7 +15,7 @@ def url(url) do
base64 = Base.url_encode64(url, @base64_opts)
sig = :crypto.hmac(:sha, secret, base64)
sig64 = sig |> Base.url_encode64(@base64_opts)
filename = Path.basename(url)
filename = Path.basename(URI.parse(url).path)
Keyword.get(config, :base_url, Pleroma.Web.base_url()) <>
"/proxy/#{sig64}/#{base64}/#{filename}"