about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_funcs.c35
-rw-r--r--src/tools/http_download.c10
2 files changed, 32 insertions, 13 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 2397ccfc..74052c9e 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -9118,7 +9118,7 @@ gboolean
 cmd_url_open(ProfWin* window, const char* const command, gchar** args)
 {
     if (window->type != WIN_CHAT && window->type != WIN_MUC && window->type != WIN_PRIVATE) {
-        cons_show("url open not supported in this window");
+        cons_show_error("url open not supported in this window");
         return TRUE;
     }
 
@@ -9134,20 +9134,37 @@ cmd_url_open(ProfWin* window, const char* const command, gchar** args)
 
     scheme = g_uri_parse_scheme(url);
     if (scheme == NULL) {
-        cons_show("URL '%s' is not valid.", args[1]);
+        cons_show_error("URL '%s' is not valid.", args[1]);
         goto out;
     }
 
     cmd_template = prefs_get_string(PREF_URL_OPEN_CMD);
     if (cmd_template == NULL) {
-        cons_show("No default `url open` command found in executables preferences.");
+        cons_show_error("No default `url open` command found in executables preferences.");
         goto out;
     }
 
 #ifdef HAVE_OMEMO
     // OMEMO URLs (aesgcm://) must be saved and decrypted before being opened.
-    if (0 == g_strcmp0(scheme, "aesgcm")) {
-        filename = unique_filename_from_url(url, files_get_data_path(DIR_DOWNLOADS));
+    if (g_strcmp0(scheme, "aesgcm") == 0) {
+
+        // Ensure that the downloads directory exists for saving cleartexts.
+        gchar* downloads_dir = files_get_data_path(DIR_DOWNLOADS);
+        if (g_mkdir_with_parents(downloads_dir, S_IRWXU) != 0) {
+            cons_show_error("Failed to create download directory "
+                            "at '%s' with error '%s'",
+                            downloads_dir, strerror(errno));
+            g_free(downloads_dir);
+            goto out;
+        }
+
+        // Generate an unique filename from the URL that should be stored in the
+        // downloads directory.
+        filename = unique_filename_from_url(url, downloads_dir);
+        g_free(downloads_dir);
+
+        // Download, decrypt and open the cleartext version of the AESGCM
+        // encrypted file.
         _url_aesgcm_method(window, cmd_template, url, filename);
         goto out;
     }
@@ -9186,15 +9203,15 @@ cmd_url_save(ProfWin* window, const char* const command, gchar** args)
 
     scheme = g_uri_parse_scheme(url);
     if (scheme == NULL) {
-        cons_show("URL '%s' is not valid.", args[1]);
+        cons_show_error("URL '%s' is not valid.", args[1]);
         goto out;
     }
 
     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);
+        cons_show_error("Failed to generate unique filename"
+                        "from URL '%s' for path '%s'",
+                        url, path);
         goto out;
     }
 
diff --git a/src/tools/http_download.c b/src/tools/http_download.c
index f97fd704..2ff49b61 100644
--- a/src/tools/http_download.c
+++ b/src/tools/http_download.c
@@ -123,7 +123,7 @@ http_file_get(void* userdata)
                                    "output file at '%s' for writing (%s).",
                                    download->url, download->filename,
                                    g_strerror(errno));
-        return NULL;
+        goto out;
     }
 
     char* cert_path = prefs_get_string(PREF_TLS_CERTPATH);
@@ -185,9 +185,6 @@ http_file_get(void* userdata)
         }
     }
 
-    download_processes = g_slist_remove(download_processes, download);
-    pthread_mutex_unlock(&lock);
-
     if (download->cmd_template != NULL) {
         gchar** argv = format_call_external_argv(download->cmd_template,
                                                  download->url,
@@ -208,6 +205,11 @@ http_file_get(void* userdata)
         free(download->cmd_template);
     }
 
+out:
+
+    download_processes = g_slist_remove(download_processes, download);
+    pthread_mutex_unlock(&lock);
+
     free(download->url);
     free(download->filename);
     free(download);
names for surrounding spaces now work' href='/akkartik/mu/commit/cpp/036closure_name?h=main&id=82ac0b7ecbc145ed8c8ecd8309166f654af1ee75'>82ac0b7e ^
a91c1c2a ^
82ac0b7e ^



2199940a ^
82ac0b7e ^
2fb94e3c ^
82ac0b7e ^





ac0e9db5 ^
05d17773 ^
82ac0b7e ^
ac0e9db5 ^
ab6ed192 ^
0487a30e ^
ac0e9db5 ^
0487a30e ^



82ac0b7e ^

0487a30e ^
82ac0b7e ^

ac0e9db5 ^
0487a30e ^
82ac0b7e ^










82ac0b7e ^


ac0e9db5 ^

82ac0b7e ^






ac0e9db5 ^
0f125d5f ^
82ac0b7e ^








ac0e9db5 ^
82ac0b7e ^


ac0e9db5 ^
0487a30e ^
82ac0b7e ^
ac0e9db5 ^
82ac0b7e ^








ac0e9db5 ^
82ac0b7e ^









ac0e9db5 ^

82ac0b7e ^

ac0e9db5 ^
0487a30e ^
82ac0b7e ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133