aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-03-06 12:02:32 -0600
committerMark Felder <feld@feld.me>2021-03-10 17:15:31 -0600
commit8246db2a968943a0cab615b8b5c1439aa4cb2547 (patch)
treeab54ac051072ef7e77b8d598528f254f90cfe762
parent8e09a3cfa05d96bb7a981207f3086203601f57a2 (diff)
downloadpleroma-8246db2a968943a0cab615b8b5c1439aa4cb2547.tar.gz
Workaround for URI.merge/2 bug https://github.com/elixir-lang/elixir/issues/10771
If we avoid URI.merge unless we know we need it we reduce the edge cases we could encounter. The site would need to both have "//" in the %URI{:path} and the image needs to be a relative URL.
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index f3f54e03d..cf8037abb 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -380,9 +380,15 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
page_url = page_url_data |> to_string
image_url =
- if is_binary(rich_media["image"]) do
- URI.merge(page_url_data, URI.parse(rich_media["image"]))
- |> to_string
+ cond do
+ !is_binary(rich_media["image"]) ->
+ nil
+
+ String.starts_with?(rich_media["image"], "http") ->
+ rich_media["image"]
+
+ true ->
+ URI.merge(page_url_data, URI.parse(rich_media["image"])) |> to_string
end
%{