talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit a0cd23ecbb4ea8b3bc76568b47e8e9451678a2cb
parent 00e802e57c96faa3ebf6a8cfca7e4c4a2c680343
Author: Ricardo Mones <ricardo@mones.org>
Date:   Sun, 21 Jun 2020 19:40:59 +0200

Fix bug 4325 "Following redirects when retrieving image"

Previously hardcoded numbers are now raised to cope with libravatar
servers changes and also moved into 3 new hidden preferences for the
plugin, for future customisation if required.

Diffstat:
Msrc/plugins/libravatar/libravatar_image.c | 8++++++--
Msrc/plugins/libravatar/libravatar_prefs.c | 9+++++++++
Msrc/plugins/libravatar/libravatar_prefs.h | 3+++
3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/plugins/libravatar/libravatar_image.c b/src/plugins/libravatar/libravatar_image.c @@ -99,8 +99,12 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); if (libravatarprefs.allow_redirects) { - long maxredirs = (libravatarprefs.default_mode == DEF_MODE_URL)? 3L - : ((libravatarprefs.default_mode == DEF_MODE_MM)? 2L: 1L); + long maxredirs = (libravatarprefs.default_mode == DEF_MODE_URL) + ? libravatarprefs.max_redirects_url + : ((libravatarprefs.default_mode == DEF_MODE_MM) + ? libravatarprefs.max_redirects_mm + : libravatarprefs.max_redirects_url); + debug_print("setting max redirects to %ld\n", maxredirs); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_MAXREDIRS, maxredirs); } diff --git a/src/plugins/libravatar/libravatar_prefs.c b/src/plugins/libravatar/libravatar_prefs.c @@ -93,6 +93,15 @@ static PrefParam param[] = { { "timeout", "0", &libravatarprefs.timeout, P_INT, NULL, NULL, NULL }, + { "max_redirects_url", "7", + &libravatarprefs.max_redirects_url, + P_INT, NULL, NULL, NULL }, + { "max_redirects_mm", "5", + &libravatarprefs.max_redirects_mm, + P_INT, NULL, NULL, NULL }, + { "max_redirects", "3", + &libravatarprefs.max_redirects, + P_INT, NULL, NULL, NULL }, {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} }; diff --git a/src/plugins/libravatar/libravatar_prefs.h b/src/plugins/libravatar/libravatar_prefs.h @@ -48,6 +48,9 @@ struct _LibravatarPrefs gboolean allow_federated; #endif guint timeout; + guint max_redirects_url; /* hidden pref */ + guint max_redirects_mm; /* hidden pref */ + guint max_redirects; /* hidden pref */ }; extern LibravatarPrefs libravatarprefs;