Correct behaviour of mediaproxy blocklist
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful

This commit is contained in:
FloatingGhost 2023-07-17 18:17:04 +01:00
parent 8fe29bf5d2
commit c8904f15a2

View file

@ -84,8 +84,13 @@ def whitelisted?(url) do
end end
def blocked?(url) do def blocked?(url) do
%{host: domain} = URI.parse(url) %{scheme: scheme, host: domain} = URI.parse(url)
domain in Config.get([:media_proxy, :whitelist]) # 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 end
defp maybe_get_domain_from_url("http" <> _ = url) do defp maybe_get_domain_from_url("http" <> _ = url) do