1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Fix bad order of parameters for url save

This commit is contained in:
William Wennerström 2020-12-07 15:15:06 +01:00
parent ac03037847
commit 4a1c118b8b
No known key found for this signature in database
GPG Key ID: E1382990BEDD319B
3 changed files with 16 additions and 3 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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);