From 30fe5f0fb9cbd07c3b7117c926c23652c583a9e6 Mon Sep 17 00:00:00 2001 From: John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> Date: Fri, 10 Nov 2023 19:54:50 +0100 Subject: [PATCH 1/2] Allow redirects for `'/plugins install ` Fix https://github.com/profanity-im/profanity/issues/1901 Suggested by @jubalh --- src/tools/http_download.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/http_download.c b/src/tools/http_download.c index b58e9290..96c8179f 100644 --- a/src/tools/http_download.c +++ b/src/tools/http_download.c @@ -159,6 +159,8 @@ http_file_get(void* userdata) curl_easy_setopt(curl, CURLOPT_USERAGENT, "profanity"); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + if (cafile) { curl_easy_setopt(curl, CURLOPT_CAINFO, cafile); } From 092b5530b2f9cd94e4bc39de6f8485dd146c0cea Mon Sep 17 00:00:00 2001 From: John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> Date: Fri, 10 Nov 2023 19:58:34 +0100 Subject: [PATCH 2/2] Add emptiness check for `/url save` and `/plugins install` Empty file is not a normal condition for file downloading, thus user has to be notifed. Related to https://github.com/profanity-im/profanity/issues/1901 --- src/tools/http_download.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tools/http_download.c b/src/tools/http_download.c index 96c8179f..89dac431 100644 --- a/src/tools/http_download.c +++ b/src/tools/http_download.c @@ -176,6 +176,10 @@ http_file_get(void* userdata) err = strdup(curl_easy_strerror(res)); } + if (ftell(outfh) == 0) { + err = strdup("Output file is empty."); + } + curl_easy_cleanup(curl); curl_global_cleanup();