diff options
author | Nick Schermer <nick@xfce.org> | 2009-03-22 09:09:16 +0000 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2009-03-22 09:09:16 +0000 |
commit | 8bb87fb690fa593add1446296a01356dd8d3247c (patch) | |
tree | 65ff83e00138cc5dd05c7ab75922a14ee558290c /exo-open | |
parent | c402c4888683b442eb9a3094fede16e41173d737 (diff) | |
download | exo-8bb87fb690fa593add1446296a01356dd8d3247c.tar.gz |
Quote arguments passed to exo-open (bug #5132).
(Old svn revision: 29679)
Diffstat (limited to 'exo-open')
-rw-r--r-- | exo-open/main.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/exo-open/main.c b/exo-open/main.c index 3967f56..2736c19 100644 --- a/exo-open/main.c +++ b/exo-open/main.c @@ -95,8 +95,10 @@ main (int argc, char **argv) GOptionContext *context; GtkWidget *dialog; GError *err = NULL; - gchar *parameter; + gchar *parameter, *quoted; gint result = EXIT_SUCCESS; + GString *join; + guint i; #ifdef GETTEXT_PACKAGE /* setup i18n support */ @@ -138,8 +140,27 @@ main (int argc, char **argv) } else if (G_LIKELY (opt_launch != NULL)) { - /* combine all specified parameters to one parameter string */ - parameter = (argc > 1) ? g_strjoinv (" ", argv + 1) : NULL; + if (argc > 1) + { + /* combine all specified parameters to one parameter string */ + join = g_string_new (NULL); + for (i = 1; argv[i] != NULL; i++) + { + /* separate the arguments */ + if (i > 1) + join = g_string_append_c (join, ' '); + + /* append the quoted argument */ + quoted = g_shell_quote (argv[i]); + join = g_string_append (join, quoted); + g_free (quoted); + } + parameter = g_string_free (join, FALSE); + } + else + { + parameter = NULL; + } /* run the preferred application */ if (!exo_execute_preferred_application (opt_launch, parameter, opt_working_directory, NULL, &err)) |