logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: 717579330427ed4f78ee578d008818c07106318f
parent: c410fe960cfc599b7ce425ad341f172780093fcf
Author: Haelwenn <contact+git.pleroma.social@hacktivis.me>
Date:   Sat, 26 Jan 2019 17:30:51 +0000

Merge branch 'hardening/mastodon-rich-media' into 'develop'

rich media: minor hardening

See merge request pleroma/pleroma!717

Diffstat:

Mlib/pleroma/web/rich_media/parser.ex12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex @@ -5,11 +5,19 @@ defmodule Pleroma.Web.RichMedia.Parser do Pleroma.Web.RichMedia.Parsers.OEmbed ] + def parse(nil), do: {:error, "No URL provided"} + if Mix.env() == :test do def parse(url), do: parse_url(url) else - def parse(url), - do: Cachex.fetch!(:rich_media_cache, url, fn _ -> parse_url(url) end) + def parse(url) do + with {:ok, data} <- Cachex.fetch(:rich_media_cache, url, fn _ -> parse_url(url) end) do + data + else + _e -> + {:error, "Parsing error"} + end + end end defp parse_url(url) do