From 4263edc9c9bbff17c7beb5495d6e7b4b4f8683ef Mon Sep 17 00:00:00 2001 From: rinpatch Date: Tue, 5 Mar 2019 18:09:23 +0300 Subject: [PATCH] Properly escape reserved URI charachters in upload urls --- lib/pleroma/upload.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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() -- 2.45.2