From: rinpatch Date: Tue, 5 Mar 2019 15:09:23 +0000 (+0300) Subject: Properly escape reserved URI charachters in upload urls X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=4263edc9c9bbff17c7beb5495d6e7b4b4f8683ef;p=akkoma Properly escape reserved URI charachters in upload urls --- diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 91a5db8c5..1a97e9fde 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -85,6 +85,10 @@ defmodule Pleroma.Upload do end end + def char_unescaped?(char) do + URI.char_unreserved?(char) or char == ?/ + end + defp get_opts(opts) do {size_limit, activity_type} = case Keyword.get(opts, :type) do @@ -218,9 +222,7 @@ defmodule Pleroma.Upload do defp url_from_spec(base_url, {:file, path}) do path = path - |> URI.encode() - |> String.replace("?", "%3F") - |> String.replace(":", "%3A") + |> URI.encode(&char_unescaped?/1) [base_url, "media", path] |> Path.join()