rich media: parser: add some basic sanity checks on the returned data with pattern...
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 28 Jan 2019 20:31:43 +0000 (20:31 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 28 Jan 2019 20:43:21 +0000 (20:43 +0000)
lib/pleroma/web/rich_media/parser.ex

index 279e27273c6f87206daae3a9ceb8a7735dfcd90a..76d977ac22a68f02a5f841f072fe998a161211cb 100644 (file)
@@ -46,11 +46,11 @@ defmodule Pleroma.Web.RichMedia.Parser do
     end)
   end
 
-  defp get_parsed_data(data) when data == %{} do
-    {:error, "No metadata found"}
+  defp get_parsed_data(%{title: title} = data) when is_binary(title) and byte_size(title) > 0 do
+    {:ok, data}
   end
 
   defp get_parsed_data(data) do
-    {:ok, data}
+    {:error, "Found metadata was invalid or incomplete: #{inspect(data)}"}
   end
 end