[Commits] [SCM] claws branch, gtk3, updated. 3.16.0-992-gbe06120af

mones at claws-mail.org mones at claws-mail.org
Fri Aug 21 17:10:32 CEST 2020


The branch, gtk3 has been updated
       via  be06120afc05caee7b08815321b2217eeca7618e (commit)
      from  b3158641ec7b6351b94a7e17cf06f4c84374ab89 (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 be06120afc05caee7b08815321b2217eeca7618e
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 0b14c6709..5e12b223a 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