From 45adb3a2422ebf3b956c33393333d62e0332cb2a Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Wed, 10 Jun 2020 15:35:16 -0400 Subject: [PATCH] meme: handle bad URL errors --- plugins/meme/meme.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/meme/meme.go b/plugins/meme/meme.go index 60cf1e5..bf51df0 100644 --- a/plugins/meme/meme.go +++ b/plugins/meme/meme.go @@ -114,7 +114,12 @@ func (p *MemePlugin) all(w http.ResponseWriter, r *http.Request) { realURL, err := url.Parse(u) if err != nil || realURL.Scheme == "" { - realURL, _ = url.Parse("https://imgflip.com/s/meme/" + u) + realURL, err = url.Parse("https://imgflip.com/s/meme/" + u) + if err != nil { + values = append(values, webResp{n, "404.png"}) + log.Error().Err(err).Msgf("invalid URL") + continue + } } values = append(values, webResp{n, realURL.String()}) }