diff --git a/lib/pleroma/web/media_proxy.ex b/lib/pleroma/web/media_proxy.ex index 29882542c..a29debbfc 100644 --- a/lib/pleroma/web/media_proxy.ex +++ b/lib/pleroma/web/media_proxy.ex @@ -5,6 +5,7 @@ defmodule Pleroma.Web.MediaProxy do alias Pleroma.Config alias Pleroma.Helpers.UriHelper + alias Pleroma.HTTP alias Pleroma.Upload alias Pleroma.Web.Endpoint alias Pleroma.Web.MediaProxy.Invalidation @@ -99,13 +100,20 @@ defmodule Pleroma.Web.MediaProxy do {base64, sig64} end + # The URL coming into MediaProxy from the outside might have wrong %-encoding + # (like older Pleroma versions) + # This would cause an inconsistency with the encoded URL here and the requested + # URL fixed with Pleroma.Tesla.Middleware.EncodeUrl. + # End result is a failing HEAD request in Pleroma.Web.MediaProxy.MediaProxyController.handle_preview/2 def encode_url(url) do + url = HTTP.encode_url(url) {base64, sig64} = base64_sig64(url) build_url(sig64, base64, filename(url)) end def encode_preview_url(url, preview_params \\ []) do + url = HTTP.encode_url(url) {base64, sig64} = base64_sig64(url) build_preview_url(sig64, base64, filename(url), preview_params)