[Commits] [SCM] claws branch, master, updated. 3.17.6-8-g62ec17880

mones at claws-mail.org mones at claws-mail.org
Fri Aug 21 17:09:47 CEST 2020


The branch, master has been updated
       via  62ec17880c8103147869e46efc0c54f7197473aa (commit)
      from  460365d085aa234c13db292afb62f7267ef5265f (commit)

Summary of changes:
 src/plugins/libravatar/libravatar.c       |  2 +-
 src/plugins/libravatar/libravatar_image.c | 15 ++++++++-------
 2 files changed, 9 insertions(+), 8 deletions(-)


- Log -----------------------------------------------------------------
commit 62ec17880c8103147869e46efc0c54f7197473aa
Author: Ricardo Mones <ricardo at mones.org>
Date:   Fri Aug 21 17:08:50 2020 +0200

    Restore behaviour of missing image mode "None"
    
    Server defaults to a predefined image so it never "fails" unless
    requested. That image is hiding failures and Face/X-Face default
    handling was never triggered, so to avoid detecting such image (which
    is prone to future error):
    
    - Force a 404 error from server if not found
    - Detect also HTTP errors on curl call
    
    Also:
    - Handle less-than-minimum files like errors and made it misses too

diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c
index dee85bba0..1ec1bec5b 100644
--- a/src/plugins/libravatar/libravatar.c
+++ b/src/plugins/libravatar/libravatar.c
@@ -208,7 +208,7 @@ static gchar *libravatar_url_for_md5(const gchar *base, const gchar *md5)
 		g_free(escaped);
 		return url;
 	} else if (libravatarprefs.default_mode == DEF_MODE_NONE) {
-		return g_strdup_printf("%s/%s?s=%u",
+		return g_strdup_printf("%s/%s?s=%u&d=404",
 				base, md5, AVATAR_SIZE);
 	}
 
diff --git a/src/plugins/libravatar/libravatar_image.c b/src/plugins/libravatar/libravatar_image.c
index 6d0fdac76..4b0bf5643 100644
--- a/src/plugins/libravatar/libravatar_image.c
+++ b/src/plugins/libravatar/libravatar_image.c
@@ -110,27 +110,28 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha
 		curl_easy_setopt(curl, CURLOPT_MAXREDIRS, maxredirs);
 	}
 	curl_easy_setopt(curl, CURLOPT_FILE, file);
+	curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); /* fail on HTTP error */
 	debug_print("retrieving URL to file: %s -> %s\n", url, filename);
 	res = curl_easy_perform(curl);
 	if (res != CURLE_OK) {
-		debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res));
+		debug_print("curl_easy_perfom failed: %s\n", curl_easy_strerror(res));
 		unlink(filename);
 		claws_fclose(file);
+		missing_add_md5(libravatarmisses, md5);
 	} else {
 		filesize = ftell(file);
 		claws_safe_fclose(file);
-		if (filesize < MIN_PNG_SIZE)
+		if (filesize < MIN_PNG_SIZE) {
 			debug_print("not enough data for an avatar image: %ld bytes\n", filesize);
-		else
+			missing_add_md5(libravatarmisses, md5);
+		} else {
 			image = image_pixbuf_from_filename(filename);
+		}
 
-		if (!libravatarprefs.cache_icons || filesize == 0) {
+		if (!libravatarprefs.cache_icons || filesize < MIN_PNG_SIZE) {
 			if (g_unlink(filename) < 0)
 				g_warning("failed to delete cache file '%s'", filename);
 		}
-
-		if (filesize == 0)
-			missing_add_md5(libravatarmisses, md5);
 	}
 
 	curl_easy_cleanup(curl);

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list