about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/cmd_funcs.c9
-rw-r--r--src/tools/aesgcm_download.c8
-rw-r--r--src/ui/console.c2
3 files changed, 16 insertions, 3 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 5b1427fe..3cff1ab5 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -4809,6 +4809,8 @@ cmd_disco(ProfWin* window, const char* const command, gchar** args)
     return TRUE;
 }
 
+// TODO(wstrm): Move this into its own tools such as HTTPUpload or
+// AESGCMDownload.
 #ifdef HAVE_OMEMO
 char*
 _add_omemo_stream(int* fd, FILE** fh, char** err)
@@ -9180,6 +9182,11 @@ cmd_url_save(ProfWin* window, const char* const command, gchar** args)
     }
 
     char* filename = unique_filename_from_url(url, path);
+    if (filename == NULL) {
+        cons_show("Failed to generate unique filename"
+                  "from URL '%s' for path '%s'",
+                  url, path);
+    }
 
     char* cmd_template = prefs_get_string_with_option(PREF_URL_SAVE_CMD, scheme);
     if (cmd_template == NULL) {
@@ -9188,7 +9195,7 @@ cmd_url_save(ProfWin* window, const char* const command, gchar** args)
             _url_http_method(window, url, filename, cmd_template);
 #ifdef HAVE_OMEMO
         } else if (g_strcmp0(scheme, "aesgcm") == 0) {
-            _url_aesgcm_method(window, url, filename, cmd_template);
+            _url_aesgcm_method(window, cmd_template, url, filename);
 #endif
         } else {
             cons_show_error("No download method defined for the scheme '%s'.", scheme);
diff --git a/src/tools/aesgcm_download.c b/src/tools/aesgcm_download.c
index f8d2db9f..20397b82 100644
--- a/src/tools/aesgcm_download.c
+++ b/src/tools/aesgcm_download.c
@@ -69,6 +69,8 @@ aesgcm_file_get(void* userdata)
     char* https_url = NULL;
     char* fragment = NULL;
 
+    // Convert the aesgcm:// URL to a https:// URL and extract the encoded key
+    // and tag stored in the URL fragment.
     if (omemo_parse_aesgcm_url(aesgcm_dl->url, &https_url, &fragment) != 0) {
         http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->url,
                                    "Download failed: Cannot parse URL '%s'.",
@@ -76,6 +78,8 @@ aesgcm_file_get(void* userdata)
         return NULL;
     }
 
+    // Create a temporary file used for storing the ciphertext that is to be
+    // retrieved from the https:// URL.
     gchar* tmpname = NULL;
     gint tmpfd;
     if ((tmpfd = g_file_open_tmp("profanity.XXXXXX", &tmpname, NULL)) == -1) {
@@ -87,6 +91,7 @@ aesgcm_file_get(void* userdata)
         return NULL;
     }
 
+    // Open the target file for storing the cleartext.
     FILE* outfh = fopen(aesgcm_dl->filename, "wb");
     if (outfh == NULL) {
         http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->url,
@@ -97,13 +102,14 @@ aesgcm_file_get(void* userdata)
         return NULL;
     }
 
+    // We wrap the HTTPDownload tool and use it for retrieving the ciphertext
+    // and storing it in the temporary file previously opened.
     HTTPDownload* http_dl = malloc(sizeof(HTTPDownload));
     http_dl->window = aesgcm_dl->window;
     http_dl->worker = aesgcm_dl->worker;
     http_dl->url = strdup(https_url);
     http_dl->filename = strdup(tmpname);
     http_dl->cmd_template = NULL;
-
     aesgcm_dl->http_dl = http_dl;
 
     http_file_get(http_dl); // TODO(wstrm): Verify result.
diff --git a/src/ui/console.c b/src/ui/console.c
index dd217105..b24fe976 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -2073,7 +2073,7 @@ cons_executable_setting(void)
     g_free(avatar);
 
     //TODO: there needs to be a way to get all the "locales"/schemes so we can
-    //display the defualt openers for all filetypes
+    //display the default openers for all filetypes
     char* urlopen = prefs_get_string_with_option(PREF_URL_OPEN_CMD, "");
     cons_show("Default '/url open' command (/executable urlopen)                        : %s", urlopen[1]);
     g_free(urlopen);