rich media: parser: only try to validate strings, not numbers (OEmbed)
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 31 Jan 2019 16:19:31 +0000 (16:19 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 31 Jan 2019 16:19:31 +0000 (16:19 +0000)
lib/pleroma/web/rich_media/parser.ex

index b33411cc7a1d95f67aa43942a24ab8fde36c23da..32dec98873e93b8df43525c5b4a951cd3f534520 100644 (file)
@@ -54,12 +54,14 @@ defmodule Pleroma.Web.RichMedia.Parser do
     {:error, "Found metadata was invalid or incomplete: #{inspect(data)}"}
   end
 
-  defp string_is_valid_unicode(data) do
+  defp string_is_valid_unicode(data) when is_binary(data) do
     data
     |> :unicode.characters_to_binary()
     |> clean_string()
   end
 
+  defp string_is_valid_unicode(data), do: {:ok, data}
+
   defp clean_string({:error, _, _}), do: {:error, "Invalid data"}
   defp clean_string(data), do: {:ok, data}