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:
parent
ac03037847
commit
4a1c118b8b
@ -4809,6 +4809,8 @@ cmd_disco(ProfWin* window, const char* const command, gchar** args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(wstrm): Move this into its own tools such as HTTPUpload or
|
||||||
|
// AESGCMDownload.
|
||||||
#ifdef HAVE_OMEMO
|
#ifdef HAVE_OMEMO
|
||||||
char*
|
char*
|
||||||
_add_omemo_stream(int* fd, FILE** fh, char** err)
|
_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);
|
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);
|
char* cmd_template = prefs_get_string_with_option(PREF_URL_SAVE_CMD, scheme);
|
||||||
if (cmd_template == NULL) {
|
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);
|
_url_http_method(window, url, filename, cmd_template);
|
||||||
#ifdef HAVE_OMEMO
|
#ifdef HAVE_OMEMO
|
||||||
} else if (g_strcmp0(scheme, "aesgcm") == 0) {
|
} else if (g_strcmp0(scheme, "aesgcm") == 0) {
|
||||||
_url_aesgcm_method(window, url, filename, cmd_template);
|
_url_aesgcm_method(window, cmd_template, url, filename);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
cons_show_error("No download method defined for the scheme '%s'.", scheme);
|
cons_show_error("No download method defined for the scheme '%s'.", scheme);
|
||||||
|
@ -69,6 +69,8 @@ aesgcm_file_get(void* userdata)
|
|||||||
char* https_url = NULL;
|
char* https_url = NULL;
|
||||||
char* fragment = 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) {
|
if (omemo_parse_aesgcm_url(aesgcm_dl->url, &https_url, &fragment) != 0) {
|
||||||
http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->url,
|
http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->url,
|
||||||
"Download failed: Cannot parse URL '%s'.",
|
"Download failed: Cannot parse URL '%s'.",
|
||||||
@ -76,6 +78,8 @@ aesgcm_file_get(void* userdata)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a temporary file used for storing the ciphertext that is to be
|
||||||
|
// retrieved from the https:// URL.
|
||||||
gchar* tmpname = NULL;
|
gchar* tmpname = NULL;
|
||||||
gint tmpfd;
|
gint tmpfd;
|
||||||
if ((tmpfd = g_file_open_tmp("profanity.XXXXXX", &tmpname, NULL)) == -1) {
|
if ((tmpfd = g_file_open_tmp("profanity.XXXXXX", &tmpname, NULL)) == -1) {
|
||||||
@ -87,6 +91,7 @@ aesgcm_file_get(void* userdata)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open the target file for storing the cleartext.
|
||||||
FILE* outfh = fopen(aesgcm_dl->filename, "wb");
|
FILE* outfh = fopen(aesgcm_dl->filename, "wb");
|
||||||
if (outfh == NULL) {
|
if (outfh == NULL) {
|
||||||
http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->url,
|
http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->url,
|
||||||
@ -97,13 +102,14 @@ aesgcm_file_get(void* userdata)
|
|||||||
return NULL;
|
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));
|
HTTPDownload* http_dl = malloc(sizeof(HTTPDownload));
|
||||||
http_dl->window = aesgcm_dl->window;
|
http_dl->window = aesgcm_dl->window;
|
||||||
http_dl->worker = aesgcm_dl->worker;
|
http_dl->worker = aesgcm_dl->worker;
|
||||||
http_dl->url = strdup(https_url);
|
http_dl->url = strdup(https_url);
|
||||||
http_dl->filename = strdup(tmpname);
|
http_dl->filename = strdup(tmpname);
|
||||||
http_dl->cmd_template = NULL;
|
http_dl->cmd_template = NULL;
|
||||||
|
|
||||||
aesgcm_dl->http_dl = http_dl;
|
aesgcm_dl->http_dl = http_dl;
|
||||||
|
|
||||||
http_file_get(http_dl); // TODO(wstrm): Verify result.
|
http_file_get(http_dl); // TODO(wstrm): Verify result.
|
||||||
|
@ -2073,7 +2073,7 @@ cons_executable_setting(void)
|
|||||||
g_free(avatar);
|
g_free(avatar);
|
||||||
|
|
||||||
//TODO: there needs to be a way to get all the "locales"/schemes so we can
|
//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, "");
|
char* urlopen = prefs_get_string_with_option(PREF_URL_OPEN_CMD, "");
|
||||||
cons_show("Default '/url open' command (/executable urlopen) : %s", urlopen[1]);
|
cons_show("Default '/url open' command (/executable urlopen) : %s", urlopen[1]);
|
||||||
g_free(urlopen);
|
g_free(urlopen);
|
||||||
|
Loading…
Reference in New Issue
Block a user