[Xfce4-commits] [xfce/thunar] 01/01: Fix escaping and unescaping URI in path entry (bug #8910)

noreply at xfce.org noreply at xfce.org
Sun May 3 18:19:52 CEST 2015


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

hjudt pushed a commit to branch master
in repository xfce/thunar.

commit a66687acff43b5b7196761514e15138706ad3385
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun May 3 17:12:53 2015 +0200

    Fix escaping and unescaping URI in path entry (bug #8910)
    
    Escaping the URI in thunar_path_entry_changed is necessary for correctly
    loading the corresponding ThunarFile for the GFile.
    
    This solves bug #8910 where the problem stems from URI unescaping,
    resulting in the unescaped text being NULL. This is handled by the
    second part of the patch, which falls back to the unescaped text.
    
    Without this commit, directories containing characters like "%", e.g
    "test%folder", can be opened but
    
    1) on remote locations the icon in the toolbar location selector will
       show an error indicating there is something wrong,
    2) while on local filesystems only the parent path will be shown in
       the path entry.
---
 thunar/thunar-path-entry.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/thunar/thunar-path-entry.c b/thunar/thunar-path-entry.c
index c5928aa..6b2ac95 100644
--- a/thunar/thunar-path-entry.c
+++ b/thunar/thunar-path-entry.c
@@ -538,6 +538,7 @@ thunar_path_entry_changed (GtkEditable *editable)
   ThunarFolder       *folder;
   GtkTreeModel       *model;
   const gchar        *text;
+  gchar              *escaped_text;
   ThunarFile         *current_folder;
   ThunarFile         *current_file;
   GFile              *folder_path = NULL;
@@ -558,7 +559,9 @@ thunar_path_entry_changed (GtkEditable *editable)
   if (G_UNLIKELY (exo_str_looks_like_an_uri (text)))
     {
       /* try to parse the URI text */
-      file_path = g_file_new_for_uri (text);
+      escaped_text = g_uri_escape_string (text, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
+      file_path = g_file_new_for_uri (escaped_text);
+      g_free (escaped_text);
 
       /* use the same file if the text assumes we're in a directory */
       if (g_str_has_suffix (text, "/"))
@@ -1082,7 +1085,7 @@ thunar_path_entry_check_completion_idle (gpointer user_data)
 
   GDK_THREADS_ENTER ();
 
-  /* check if the user entered atleast part of a filename */
+  /* check if the user entered at least part of a filename */
   text = gtk_entry_get_text (GTK_ENTRY (path_entry));
   if (*text != '\0' && text[strlen (text) - 1] != '/')
     {
@@ -1195,6 +1198,8 @@ thunar_path_entry_set_current_file (ThunarPathEntry *path_entry,
     }
 
   unescaped = g_uri_unescape_string (text, NULL);
+  if (unescaped == NULL)
+    unescaped = g_strdup (text);
   g_free (text);
 
   /* setup the entry text */

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


More information about the Xfce4-commits mailing list