diff options
author | lambda <pleromagit@rogerbraun.net> | 2018-04-07 12:19:49 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2018-04-07 12:19:49 +0000 |
commit | d41bfd1d47587c95450c5953b9fb4374008ecb8c (patch) | |
tree | 69ca80a83e449593cb8a208885b18ba7731ae760 | |
parent | 2dc0c419468c2c336a0a14513049e838e972fce4 (diff) | |
parent | bf9d3d4abaecc4e842c38866f039ebd8f5f96948 (diff) | |
download | pleroma-d41bfd1d47587c95450c5953b9fb4374008ecb8c.tar.gz |
Merge branch 'bugfix/html-webfinger-host-meta' into 'develop'
webfinger: handle situations where the well-known endpoint returns HTML
See merge request pleroma/pleroma!94
-rw-r--r-- | lib/pleroma/web/xml/xml.ex | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml/xml.ex index b85712d65..8b609f695 100644 --- a/lib/pleroma/web/xml/xml.ex +++ b/lib/pleroma/web/xml/xml.ex @@ -4,14 +4,20 @@ defmodule Pleroma.Web.XML do def string_from_xpath(_, :error), do: nil def string_from_xpath(xpath, doc) do - {:xmlObj, :string, res} = :xmerl_xpath.string('string(#{xpath})', doc) + try do + {:xmlObj, :string, res} = :xmerl_xpath.string('string(#{xpath})', doc) - res = - res - |> to_string - |> String.trim() + res = + res + |> to_string + |> String.trim() - if res == "", do: nil, else: res + if res == "", do: nil, else: res + catch + e -> + Logger.debug("Couldn't find xpath #{xpath} in XML doc") + nil + end end def parse_document(text) do |