diff options
Diffstat (limited to 'lib/pleroma/web/xml/xml.ex')
-rw-r--r-- | lib/pleroma/web/xml/xml.ex | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml/xml.ex index 22faf72df..63580c1f8 100644 --- a/lib/pleroma/web/xml/xml.ex +++ b/lib/pleroma/web/xml/xml.ex @@ -1,4 +1,7 @@ defmodule Pleroma.Web.XML do + require Logger + + def string_from_xpath(xpath, :error), do: nil def string_from_xpath(xpath, doc) do {:xmlObj, :string, res} = :xmerl_xpath.string('string(#{xpath})', doc) @@ -10,10 +13,16 @@ defmodule Pleroma.Web.XML do end def parse_document(text) do - {doc, _rest} = text - |> :binary.bin_to_list - |> :xmerl_scan.string + try do + {doc, _rest} = text + |> :binary.bin_to_list + |> :xmerl_scan.string - doc + doc + catch + :exit, error -> + Logger.debug("Couldn't parse xml: #{inspect(text)}") + :error + end end end |