media_proxy: use path only to retrieve filename
authorhref <href@random.sh>
Tue, 13 Nov 2018 22:41:33 +0000 (23:41 +0100)
committerhref <href@random.sh>
Tue, 13 Nov 2018 22:41:33 +0000 (23:41 +0100)
lib/pleroma/web/media_proxy/controller.ex
lib/pleroma/web/media_proxy/media_proxy.ex

index 10e6b4e52e90d5d000695ac851c31b77c9b43ca2..bb257c2622f87515cb2df5d9e222d9b5f4c84ab4 100644 (file)
@@ -30,7 +30,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController 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),
index 6819c0917846674d84013f902541d98c6aa80150..93c36b4ed3668f15634bed6c49402772c436a418 100644 (file)
@@ -15,7 +15,7 @@ defmodule Pleroma.Web.MediaProxy 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}"