After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 523139 - nautilus does not remove file '_x' from trash
nautilus does not remove file '_x' from trash
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: trash backend
git master
Other All
: High normal
: ---
Assigned To: Christian Neumair
gvfs-maint
: 529446 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-03-18 11:27 UTC by Sebastien Bacher
Modified: 2008-06-11 15:16 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
Proposed patch (2.26 KB, patch)
2008-03-30 19:08 UTC, Christian Neumair
none Details | Review
Use hex escape codes for trash (un)escape_pathname. (2.12 KB, patch)
2008-05-13 22:48 UTC, Andreas Henriksson
committed Details | Review

Description Sebastien Bacher 2008-03-18 11:27:40 UTC
The bug has been opened on https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/203195

"Steps to reproduce on hardy:
1. Create a file on a partition that is not the home-partition an begins with a '_', e.g. _x or __init__.py
    $ touch /mnt/Daten/barcc/Projekte/_x
2. $ nautilus /mnt/Daten/barcc/Projekte/
    and delete the file (del). Now it is in /mnt/Daten/.Trash-1000/
3. Now open the Trash: $ nautilus Trash:///
  a) Press the 'Empty Deleted Items' button
      -> All files are removed except the file _x
  b) Select the file _x and hit DEL and confirm the are-you-sure-dialog.
      -> Now there is a dialog containing the text:
-------------------------------------------------------------
Fehler beim Löschen.
Es ist ein Fehler beim Einlesen der Informationen über »mnt_Daten_.Trash-1000___x« aufgetreten.

  Weitere Details anzeigen
Fehler beim Untersuchen der Datei /mnt/Daten/.Trash-1000_/files/x mit fstat(): No such file or directory
-------------------------------------------------------------"
Comment 1 Christian Neumair 2008-03-30 10:51:58 UTC
Good catch! Moving to gvfs.

The issue is that we internally use an escaping mechanism in the trash GVFS backend:

gvfsbackendtrash.c:escape_pathname()
gvfsbackendtrash.c:unescape_pathname()

'/' is converted to '_', and '_' to "__".

This implies the following conversions:

"/a_b/c" => "_a__b_c"
"/a_/c" => "_a___c"
"/a/_c" => "_a___c"

As you can see, two different file names ar emapped to the same escaped name.

Confirming, raising priority.
Comment 2 Christian Neumair 2008-03-30 19:08:25 UTC
Created attachment 108285 [details] [review]
Proposed patch

The attached patch changes the escaping routine to convert
  "/_" to "__ _"
  "/   _" to "_    __"
  "/any-number-of-spaces_" to "/one-space-more_"

That said, if we encounter "/_" or "/..._" [where ... is any non-zero number of spaces], we insert an additional stuffing space. Later, during decoding, we will simply remove the stuffing space again. However, in the "/_" case it ensures that we don't decode it to "_/".
Comment 3 Matthias Clasen 2008-04-21 18:19:49 UTC
Whats wrong with hex escapes ? that seems much more straightforward than this convoluted custom scheme.
Comment 4 A. Walton 2008-04-22 22:32:51 UTC
*** Bug 529446 has been marked as a duplicate of this bug. ***
Comment 5 Andreas Henriksson 2008-05-13 22:48:31 UTC
Created attachment 110879 [details] [review]
Use hex escape codes for trash (un)escape_pathname.

In my tests, the attached patch fixes the problem (including being able to delete files in trash deleted with plain gvfs that where stuck in trash).

Doing this simple test revealed a minor problem:
touch _test  _test_  %test%  test%25test  test%2ftest  test%5ftest
gvfs-trash *test*

They don't pose a problem for cleaning the trashcan, but they show up *unescaped* (without first having been escaped) when you /view/ the trashcan contents!
Comment 6 Andreas Henriksson 2008-05-13 23:10:52 UTC
I should probably mention that the minor problem seems to happen also with plain gvfs 0.2.3, thus not introduced by the patch.
Comment 7 A. Walton 2008-05-22 13:10:17 UTC
(In reply to comment #5)
> Created an attachment (id=110879) [edit]
> Use hex escape codes for trash (un)escape_pathname.
> 
> In my tests, the attached patch fixes the problem (including being able to
> delete files in trash deleted with plain gvfs that where stuck in trash).
> 

Then we should probably go ahead and use this patch, as it's the right thing to do.

> Doing this simple test revealed a minor problem:
> touch _test  _test_  %test%  test%25test  test%2ftest  test%5ftest
> gvfs-trash *test*
> 
> They don't pose a problem for cleaning the trashcan, but they show up
> *unescaped* (without first having been escaped) when you /view/ the trashcan
> contents!
> 

We definitely escape the string in GIO before adding it to the keyfile, and we definitely unescape the string before we set the display name using it inside of GVFS. The problem is that we only escaped characters into hex encoding inside of GIO, so any already hex-encoded text is passed through untouched (and gets unescaped when set as the display-name inside of GVFS). 

It's definitely an unintended consequence, but I really don't think it's common enough that we should worry about it over restoring this functionality (it's pretty hard on users). If I'm wrong, please say so, but I can't find a single file on my filesystem that uses hex encoding as a part of its real filename. Any user that might end up confused by this could open the files and inspect them.

If the latter really is a problem, we should think about some other encoding scheme, and it will likely require an update of the Trash specification.
Comment 8 Andreas Henriksson 2008-05-22 21:32:12 UTC
(In reply to comment #7)
[...]
> It's definitely an unintended consequence, but I really don't think it's common
> enough that we should worry about it over restoring this functionality (it's
> pretty hard on users).

All I meant was, this is a bug which I don't care to fix. I was just interested in mentioning to make sure it's knows, since I ran into it. If anyone cares, feel free to open a bugreport about it! :)

I'm happy as long as I can empty my trash. Would be nice to see the patch committed and this bug closed. ;)

Comment 9 A. Walton 2008-06-11 15:16:13 UTC
Gicmo gave permission, so I committed it on your behalf. Thanks!

2008-06-11  A. Walton  <awalton@gnome.org>

	* daemon/gvfsbackendtrash.c (escape_pathname), (unescape_pathname):
	Use hex escapes in the trash backend. 
	Patch by Andreas Henriksson.
	Fixes bug #523139.