Properly escape reserved URI charachters in upload urls

This commit is contained in:
rinpatch 2019-03-05 18:09:23 +03:00
parent 10248d86a2
commit 4263edc9c9

View File

@ -85,6 +85,10 @@ defmodule Pleroma.Upload do
end end
end end
def char_unescaped?(char) do
URI.char_unreserved?(char) or char == ?/
end
defp get_opts(opts) do defp get_opts(opts) do
{size_limit, activity_type} = {size_limit, activity_type} =
case Keyword.get(opts, :type) do case Keyword.get(opts, :type) do
@ -218,9 +222,7 @@ defmodule Pleroma.Upload do
defp url_from_spec(base_url, {:file, path}) do defp url_from_spec(base_url, {:file, path}) do
path = path =
path path
|> URI.encode() |> URI.encode(&char_unescaped?/1)
|> String.replace("?", "%3F")
|> String.replace(":", "%3A")
[base_url, "media", path] [base_url, "media", path]
|> Path.join() |> Path.join()