From 551a829eba5c5a5ff8ee94d47da792644cbb19e2 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 24 Apr 2020 17:51:13 +0100 Subject: [PATCH] googlephotos: don't put an image in error message - fixes #4144 For a certain class of broken or missing image Google Photos puts an image in the error message. Before this fix we blindly chucked it into the error message. After this fix we replace it with some sensible text. --- backend/googlephotos/googlephotos.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/googlephotos/googlephotos.go b/backend/googlephotos/googlephotos.go index e8bc2b371..6f5abd105 100644 --- a/backend/googlephotos/googlephotos.go +++ b/backend/googlephotos/googlephotos.go @@ -235,6 +235,10 @@ func errorHandler(resp *http.Response) error { if err != nil { body = nil } + // Google sends 404 messages as images so be prepared for that + if strings.HasPrefix(resp.Header.Get("Content-Type"), "image/") { + body = []byte("Image not found or broken") + } var e = api.Error{ Details: api.ErrorDetails{ Code: resp.StatusCode,