From 788b109b39fc6e507490178b24020d9bf459e306 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 29 Apr 2007 11:48:40 +0000 Subject: [PATCH] Quote the passed command line... 2007-04-29 Emmanuele Bassi * glib/gbookmarkfile.c: (g_bookmark_file_set_app_info): Quote the passed command line... (g_bookmark_file_get_app_info): ... and unquote it when giving it back. (#432274) svn path=/trunk/; revision=5466 --- ChangeLog | 8 ++++++++ glib/gbookmarkfile.c | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 775f37d..2dc77f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-04-29 Emmanuele Bassi + + * glib/gbookmarkfile.c: + (g_bookmark_file_set_app_info): Quote the passed command line... + + (g_bookmark_file_get_app_info): ... and unquote it when giving it + back. (#432274) + 2007-04-27 Matthias Clasen * glib/gstrfuncs.c: small coding style cleanups. diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c index dd95fff..6f9f99b 100644 --- a/glib/gbookmarkfile.c +++ b/glib/gbookmarkfile.c @@ -3257,7 +3257,7 @@ g_bookmark_file_set_app_info (GBookmarkFile *bookmark, if (exec && exec[0] != '\0') { g_free (ai->exec); - ai->exec = g_strdup (exec); + ai->exec = g_shell_quote (exec); } item->modified = time (NULL); @@ -3338,7 +3338,9 @@ expand_exec_line (const gchar *exec_fmt, * @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the * event that no application with name @app_name has registered a bookmark * for @uri, %FALSE is returned and error is set to - * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. + * #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting + * the command line fails, an error of the #G_SHELL_ERROR domain is + * set and %FALSE is returned. * * Return value: %TRUE on success. * @@ -3383,15 +3385,29 @@ g_bookmark_file_get_app_info (GBookmarkFile *bookmark, if (exec) { - *exec = expand_exec_line (ai->exec, uri); + GError *unquote_error = NULL; + gchar *command_line; + + command_line = g_shell_unquote (ai->exec, &unquote_error); + if (unquote_error) + { + g_propagate_error (unquote_error, error); + return FALSE; + } + + *exec = expand_exec_line (command_line, uri); if (!*exec) { g_set_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_INVALID_URI, _("Failed to expand exec line '%s' with URI '%s'"), ai->exec, uri); + g_free (command_line); + return FALSE; } + else + g_free (command_line); } if (count) -- 2.7.4