diff options
author | portix <none@none> | 2012-12-17 23:37:12 +0100 |
---|---|---|
committer | portix <none@none> | 2012-12-17 23:37:12 +0100 |
commit | 208ad2eb4dd5a56164861df8b1990eb9ad1a74a7 (patch) | |
tree | 4a8ddcf35fe4794be13ed777f79806961c026302 /src/download.c | |
parent | 2156e0e0ef519ab0b7e397c6548027597b24930c (diff) | |
download | dwb-208ad2eb4dd5a56164861df8b1990eb9ad1a74a7.zip |
Escape download path when spawning with application; use g_shell_parse_argv to parse command
Diffstat (limited to 'src/download.c')
-rw-r--r-- | src/download.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/download.c b/src/download.c index b84047fd..7eabf114 100644 --- a/src/download.c +++ b/src/download.c @@ -235,18 +235,21 @@ static void download_do_spawn(const char *command, const char *path, const char *mimetype) { GError *error = NULL; - char *argv[64]; + char **argv; + int argc; + char *unescaped; if (g_str_has_prefix(path, "file://")) path += 7; - char **argcom = g_strsplit(command, " ", -1); + if (!g_shell_parse_argv(command, &argc, &argv, NULL)) + return; + + argv = g_realloc(argv, (argc+2) * sizeof(char*)); - guint argc=0; - for (; argc<g_strv_length(argcom) && argc<62; argc++) - argv[argc] = argcom[argc]; + unescaped = g_uri_unescape_string(path, NULL); - argv[argc++] = (char *)path; + argv[argc++] = unescaped; argv[argc++] = NULL; if (! g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error) ) @@ -255,7 +258,6 @@ download_do_spawn(const char *command, const char *path, const char *mimetype) g_clear_error(&error); } /* Set mimetype */ - g_strfreev(argcom); GList *list = NULL; if (mimetype && *mimetype) { @@ -268,6 +270,7 @@ download_do_spawn(const char *command, const char *path, const char *mimetype) dwb.fc.mimetypes = g_list_prepend(dwb.fc.mimetypes, n); util_file_add_navigation(dwb.files[FILES_MIMETYPES], n, true, -1); } + g_strfreev(argv); }/*}}}*/ /* download_spawn(DwbDownload *) {{{*/ static void |