diff options
author | Nick Schermer <nick@xfce.org> | 2009-07-10 18:24:36 +0000 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2009-07-10 18:24:36 +0000 |
commit | f578ac2d91d63241af2db9987e6b94514f5d183e (patch) | |
tree | f4a1ada1e928624b6da41b910d7b98a1534261d4 /exo-open | |
parent | ce99ab4f0dbe661236c8a2fe3eca4620f41d8ac1 (diff) | |
download | exo-f578ac2d91d63241af2db9987e6b94514f5d183e.tar.gz |
Fix quotes in urls, only quote when the arg contains spaces (bug #5461).
(Old svn revision: 30251)
Diffstat (limited to 'exo-open')
-rw-r--r-- | exo-open/main.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/exo-open/main.c b/exo-open/main.c index cbf5074..96bd1ba 100644 --- a/exo-open/main.c +++ b/exo-open/main.c @@ -36,6 +36,16 @@ #include <exo/exo.h> +/** + * For testing this code the following commands should work: + * + * exo-open --launch WebBrowser http://xfce.org (bug #5461). + * exo-open http://xfce.org + * exo-open --launch TerminalEmulator ./script.sh 'something with a space' 'nospace' (bug #5132). + * exo-open --launch TerminalEmulator ssh -l username some.host.com + **/ + + static gboolean opt_help = FALSE; static gboolean opt_version = FALSE; @@ -143,6 +153,8 @@ main (int argc, char **argv) { if (argc > 1) { + /* NOTE: see the comment at the top of this document! */ + /* combine all specified parameters to one parameter string */ join = g_string_new (NULL); for (i = 1; argv[i] != NULL; i++) @@ -150,11 +162,18 @@ main (int argc, char **argv) /* 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); + + /* only quote arguments with spaces */ + if (strchr (argv[i], ' ') != NULL) + { + quoted = g_shell_quote (argv[i]); + join = g_string_append (join, quoted); + g_free (quoted); + } + else + { + join = g_string_append (join, argv[i]); + } } parameter = g_string_free (join, FALSE); } @@ -163,6 +182,10 @@ main (int argc, char **argv) parameter = NULL; } +#ifndef NDEBUG + g_message ("launch=%s, wd=%s, parameters (%d)=%s", opt_launch, opt_working_directory, argc, parameter); +#endif + /* run the preferred application */ if (!exo_execute_preferred_application (opt_launch, parameter, opt_working_directory, NULL, &err)) { |