From 0f11254a065d014d8fbb4f4a48cb03d14d8e02d0 Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Mon, 28 Jan 2019 20:31:43 +0000
Subject: [PATCH] rich media: parser: add some basic sanity checks on the
 returned data with pattern matching

---
 lib/pleroma/web/rich_media/parser.ex | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex
index 279e27273..76d977ac2 100644
--- a/lib/pleroma/web/rich_media/parser.ex
+++ b/lib/pleroma/web/rich_media/parser.ex
@@ -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