[Xfce4-commits] [xfce/thunar] 01/01: Thunar's "open with" custom command doesn't escape the path (bug #10883)

noreply at xfce.org noreply at xfce.org
Wed Jan 31 23:21:32 CET 2018


This is an automated email from the git hooks/post-receive script.

a   l   e   x       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit 441d99d9052fea46431a5df3ee9def5487b1069e
Author: Alexander Schwinn <acs82 at gmx.de>
Date:   Wed Jan 31 23:18:44 2018 +0100

    Thunar's "open with" custom command doesn't escape the path (bug #10883)
---
 thunar/thunar-chooser-dialog.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/thunar/thunar-chooser-dialog.c b/thunar/thunar-chooser-dialog.c
index 782967b..72addcd 100644
--- a/thunar/thunar-chooser-dialog.c
+++ b/thunar/thunar-chooser-dialog.c
@@ -391,13 +391,11 @@ thunar_chooser_dialog_response (GtkDialog *widget,
   GtkTreeModel        *model;
   GtkTreeIter          iter;
   const gchar         *content_type;
-  const gchar         *exec;
   GAppInfo            *app_info = NULL;
   gboolean             succeed = TRUE;
   GError              *error = NULL;
   gchar               *path;
   gchar               *name;
-  gchar               *s;
   GList                list;
   GdkScreen           *screen;
 
@@ -417,26 +415,20 @@ thunar_chooser_dialog_response (GtkDialog *widget,
     }
   else
     {
-      /* determine the command line for the custom command */
-      exec = gtk_entry_get_text (GTK_ENTRY (dialog->custom_entry));
+      /* Wrap the path into double quotes in order to support spaces in file/folder names */
+      path = g_strconcat ("\"", gtk_entry_get_text (GTK_ENTRY (dialog->custom_entry)), "\"", NULL);
 
-      /* determine the path for the custom command */
-      path = g_strdup (exec);
-      s = strchr (path, ' ');
-      if (G_UNLIKELY (s != NULL))
-        *s = '\0';
-
-      /* determine the name from the path of the custom command */
+      /* determine the name of the custom command */
       name = g_path_get_basename (path);
 
       /* try to add an application for the custom command */
-      app_info = g_app_info_create_from_commandline (exec, name, G_APP_INFO_CREATE_NONE, &error);
+      app_info = g_app_info_create_from_commandline (path, name, G_APP_INFO_CREATE_NONE, &error);
 
       /* verify the application */
       if (G_UNLIKELY (app_info == NULL))
         {
           /* display an error to the user */
-          thunar_dialogs_show_error (GTK_WIDGET (dialog), error, _("Failed to add new application \"%s\""), name);
+          thunar_dialogs_show_error (GTK_WIDGET (dialog), error, _("Failed to add new application \"%s\""), path);
 
           /* release the error */
           g_error_free (error);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list