From c8904f15a2604e5fa808b668c050ac16ae727523 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Mon, 17 Jul 2023 18:17:04 +0100 Subject: [PATCH] Correct behaviour of mediaproxy blocklist --- lib/pleroma/web/media_proxy.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/media_proxy.ex b/lib/pleroma/web/media_proxy.ex index 9a5f47716..44f927dba 100644 --- a/lib/pleroma/web/media_proxy.ex +++ b/lib/pleroma/web/media_proxy.ex @@ -84,8 +84,13 @@ def whitelisted?(url) do end def blocked?(url) do - %{host: domain} = URI.parse(url) - domain in Config.get([:media_proxy, :whitelist]) + %{scheme: scheme, host: domain} = URI.parse(url) + # Block either the bare domain or the scheme-domain combo + scheme_domain = "#{scheme}://#{domain}" + blocklist = Config.get([:media_proxy, :blocklist]) + + Enum.member?(blocklist, domain) || + Enum.member?(blocklist, scheme_domain) end defp maybe_get_domain_from_url("http" <> _ = url) do