! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
wrong thunar-path-entry unescape and locale names handling (patch included)
Status:
RESOLVED: FIXED

Comments

Description Dimitar Zhekov 2011-07-30 20:21:42 CEST
Created attachment 3804 
a patch that fixes thunar-path-entry unescape and the locale names handling

When a file name is being placed in the path bar entry, it's unescaped first. If you create a directory name like "foo%20bar" and enter it, the entry will contain "foo bar", and will behave as if a missing directory name is typed.

OTOH, ftp file names containing spaces will be displayed with space instead of "%20" even without an explicit unescape.

Another problem is that thunar_path_entry_set_current_file() receives real file names and places them into the entry without converting to utf-8, thus breaking any file names with non-utf-8 encoding - the locale characters are displayed with the replacement character, and of course, neither completion nor any action with them works.

So I replaced g_uri_unescape_string() with g_filename_display_name(). Of course, glib manual warns that such conversion may be irreversible; but that only applies to names which can not be converted to utf-8, and such names will be always be broken when placed in the (utf-8) entry.

Last, the entry completion functions compare the (utf-8) entry text against the real file names. That does does not work for locale names, and sometimes a g_assert() for a NULL string is displayed (probably a result of g_utf8_normalize(real_name), but I haven't tested that). Luckily enough, we have a utf-8 name corresponding to the real name - it's the display name, which fits with our new entry text.

With ext2, which supports local and utf-8 encodings simultaneously, both are be displayed and completed correctly - but for locale names, the entry behaves as if a missing name is typed (the GTK+ Open/Save dialog works in exactly the same way). With G_BROKEN_FILENAMES or G_FILENAME_ENCODING set, the locale names work completely - but of course, any utf-8 names are displayed and completed as if they are 8-bit.

Overall, IMHO, the patch improves the handling of locale names, and does not break the utf-8 names. It's really small and trivial.
Comment 1 Jannis Pohlmann editbugs 2011-09-17 00:22:29 CEST
First of all, I cannot reproduce the "foo%20bar" vs. "foo bar" issue. If using the location bar, "foo%20bar" and "foo bar" are displayed as "foo bar" and I can enter them by either typing "foo%20bar" or "foo bar".

The rest of your comments may be valid, I haven't checked that yet. Just a general thought: we might be able to escape the conversion madness by using G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME in places where it is appropriate. I'd prefer to get rid of any character-set-related code where possible.
Comment 2 Dimitar Zhekov 2011-09-17 18:43:39 CEST
Created attachment 3867 
completion with unescaped name
Comment 3 Dimitar Zhekov 2011-09-17 18:44:12 CEST
Created attachment 3868 
completion with escaped name
Comment 4 Dimitar Zhekov 2011-09-17 18:47:32 CEST
I'm sending screen shots (a small part of the screen of course) with filename completion using the unescaped and escaped names. Should be self-explaining.
Comment 5 Nick Schermer editbugs 2012-09-29 21:06:31 CEST
Works fine here. Please reopen if this is still an issue with the latest Thunar release.
Comment 6 Dimitar Zhekov 2013-06-08 19:19:33 CEST
Created attachment 5059 
New_Folder_No_Foo.png
Comment 7 Dimitar Zhekov 2013-06-08 19:20:20 CEST
Created attachment 5060 
New_Folder_Bar
Comment 8 Dimitar Zhekov 2013-06-08 19:21:54 CEST
Created attachment 5061 
New_Folder
Comment 9 Dimitar Zhekov 2013-06-08 19:30:18 CEST
Created attachment 5062 
Locale_AB
Comment 10 Dimitar Zhekov 2013-06-08 19:37:53 CEST
I checked 1.6.3. Now let's create a good and easy to reproduce example...

$ mkdir ~/'New%20Folder'
$ touch ~/'New%20Folder/Foo'
$ mkdir ~/'New Folder'
$ touch ~/'New Folder/Bar'
$ thunar ~/'New%20Folder'

The path bar entry contains "New Folder". Let's try to complete it with /F for Foo...

<New_Folder_No_Foo.png>

nothing happens. How about /B then?

<New_Folder_Bar.png>

Wow, completes Bar - from the other directory. :)

The only difference from 1.2.3 and 1.6.3 is that if "New%20Folder" exists, but "New Folder" does not, opening "New%20Folder" with 1.6.3 displays the red stop sign immediately:

<New_Folder.png>

whereas 1.2.3 shows it when you attempt completion.

I hope my explanation was better this time. There can't be "works for me", since the same "New"<space>"Folder" text in the path bar simply can not refer correctly to two different directories.

--

As of the locale names, there is no change either:

<Locale_AB.png>

I haven't checked the 1.6.3 source, but most likely it still puts the raw locale name in the UTF-8 path bar entry.
Comment 11 Harald Judt editbugs 2015-05-04 22:05:27 CEST
I have found this bug report after I have tried to fix the same issue as described in bug #8190.

Can someone please compile current git and see if the issue is fixed, or if there are any problems with my fixes?

http://git.xfce.org/xfce/thunar/commit/?id=a66687acff43b5b7196761514e15138706ad3385
http://git.xfce.org/xfce/thunar/commit/?id=bfa875b6a76f812d638f2e88ea27a2cf95e5be1f

Related fix for the bookmarks in the shortcut pane:
http://git.xfce.org/xfce/thunar/commit/?id=65adfa6552f2211e51caa0c23ecbbefc5ab96362
Comment 12 Harald Judt editbugs 2015-05-12 11:45:12 CEST
I'm closing this, as the current implementation seems fine and no one else has reported any problems.

Bug #7857

Reported by:
Dimitar Zhekov
Reported on: 2011-07-30
Last modified on: 2015-05-12

People

Assignee:
Jannis Pohlmann
CC List:
2 users

Version

Version:
Migration to GIO

Attachments

a patch that fixes thunar-path-entry unescape and the locale names handling (3.07 KB, patch)
2011-07-30 20:21 CEST , Dimitar Zhekov
no flags
completion with unescaped name (11.69 KB, image/png)
2011-09-17 18:43 CEST , Dimitar Zhekov
no flags
completion with escaped name (10.86 KB, image/png)
2011-09-17 18:44 CEST , Dimitar Zhekov
no flags
New_Folder_No_Foo.png (42.74 KB, image/png)
2013-06-08 19:19 CEST , Dimitar Zhekov
no flags
New_Folder_Bar (41.54 KB, image/png)
2013-06-08 19:20 CEST , Dimitar Zhekov
no flags
New_Folder (42.95 KB, image/png)
2013-06-08 19:21 CEST , Dimitar Zhekov
no flags
Locale_AB (13.08 KB, image/png)
2013-06-08 19:30 CEST , Dimitar Zhekov
no flags

Additional information