diff options
author | lain <lain@soykaf.club> | 2020-08-25 17:35:59 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-08-25 17:35:59 +0200 |
commit | 112bec52252108de57e708ed47cf43abd9f3b2f1 (patch) | |
tree | deb475863937ab5df378e80f7f41817fa8bc437d /lib | |
parent | 361aa22e2862c1c914baf8257fdc8b20cbc7941d (diff) | |
download | pleroma-112bec52252108de57e708ed47cf43abd9f3b2f1.tar.gz |
Webfinger: Handle bogus ids better.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/web_finger/web_finger.ex | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex index 71ccf251a..c4051e63e 100644 --- a/lib/pleroma/web/web_finger/web_finger.ex +++ b/lib/pleroma/web/web_finger/web_finger.ex @@ -149,6 +149,18 @@ defmodule Pleroma.Web.WebFinger do end end + defp get_address_from_domain(domain, encoded_account) when is_binary(domain) do + case find_lrdd_template(domain) do + {:ok, template} -> + String.replace(template, "{uri}", encoded_account) + + _ -> + "https://#{domain}/.well-known/webfinger?resource=#{encoded_account}" + end + end + + defp get_address_from_domain(_, _), do: nil + @spec finger(String.t()) :: {:ok, map()} | {:error, any()} def finger(account) do account = String.trim_leading(account, "@") @@ -163,16 +175,8 @@ defmodule Pleroma.Web.WebFinger do encoded_account = URI.encode("acct:#{account}") - address = - case find_lrdd_template(domain) do - {:ok, template} -> - String.replace(template, "{uri}", encoded_account) - - _ -> - "https://#{domain}/.well-known/webfinger?resource=#{encoded_account}" - end - - with response <- + with address when is_binary(address) <- get_address_from_domain(domain, encoded_account), + response <- HTTP.get( address, [{"accept", "application/xrd+xml,application/jrd+json"}] |