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 170437 - [PATCH] Beagle does not index filenames containing "\".
[PATCH] Beagle does not index filenames containing "\".
Status: RESOLVED FIXED
Product: beagle
Classification: Other
Component: General
unspecified
Other All
: High normal
: Milestone 1.5
Assigned To: Jon Trowbridge
Jon Trowbridge
: 172244 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-03-15 11:36 UTC by Veerapuram Varadhan
Modified: 2005-04-05 05:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Part-1 fix (933 bytes, patch)
2005-03-15 20:43 UTC, Veerapuram Varadhan
none Details | Review
Handle '\' cases. (4.72 KB, patch)
2005-03-18 14:37 UTC, Veerapuram Varadhan
none Details | Review
Handle '\' cases properly and do not spew out exception traces. (4.72 KB, patch)
2005-03-18 14:37 UTC, Veerapuram Varadhan
none Details | Review

Description Veerapuram Varadhan 2005-03-15 11:36:25 UTC
Please describe the problem:


Steps to reproduce:
1. Create a text file with a name that contains a "\" char.
2. Try to index it with beagle
3. 


Actual results:
Beagle throws the following exception:

DEBUG: *** What should we do with /home/varadhan/samples/beagle's\ test.txt?
DEBUG: *** No attributes on /home/varadhan/samples/beagle's\ test.txt
ERROR: Caught exception inside Inotify.Event
ERROR: System.NullReferenceException: Object reference not set to an instance of
an object
in [0x0004d] (at
/home/varadhan/work/cvs/beagle-cvs/beagle/beagled/FileSystemQueryable/FileSystemModel.cs:954)
Beagle.Daemon.FileSystemQueryable.FileSystemModel:PathToUid (string)
in [0x00002] (at
/home/varadhan/work/cvs/beagle-cvs/beagle/beagled/FileSystemQueryable/FileSystemModel.cs:962)
Beagle.Daemon.FileSystemQueryable.FileSystemModel:PathToInternalUri (string)
in [0x00007] (at
/home/varadhan/work/cvs/beagle-cvs/beagle/beagled/FileSystemQueryable/FileSystemModel.cs:967)
Beagle.Daemon.FileSystemQueryable.FileSystemModel:ToInternalUri (System.Uri)
in [0x00034] (at
/home/varadhan/work/cvs/beagle-cvs/beagle/beagled/FileSystemQueryable/FileSystemQueryable.cs:114)
Beagle.Daemon.FileSystemQueryable.FileSystemQueryable:Add (string)
in [0x00201] (at
/home/varadhan/work/cvs/beagle-cvs/beagle/beagled/FileSystemQueryable/InotifyBackend.cs:173)
Beagle.Daemon.FileSystemQueryable.InotifyBackend:OnInotifyEvent
(int,string,string,string,Beagle.Util.Inotify/EventType)
in <0x00057> (wrapper delegate-invoke)
System.MulticastDelegate:invoke_void_int_string_string_string_Inotify/EventType
(int,string,string,string,Beagle.Util.Inotify/EventType)
in <0x00034> (wrapper delegate-invoke)
System.MulticastDelegate:invoke_void_int_string_string_string_Inotify/EventType
(int,string,string,string,Beagle.Util.Inotify/EventType)
in [0x000a7] (at /home/varadhan/work/cvs/beagle-cvs/beagle/Util/Inotify.cs:471)
Beagle.Util.Inotify:SendEvent
(Beagle.Util.Inotify/Watched,string,string,Beagle.Util.Inotify/EventType)


Expected results:
Beagle should index the file

Does this happen every time?
Yes

Other information:
Comment 1 Veerapuram Varadhan 2005-03-15 14:28:00 UTC
Fix is in my local tree.  Will attach the patch soon.
Comment 2 Veerapuram Varadhan 2005-03-15 20:43:59 UTC
Created attachment 38767 [details] [review]
Part-1 fix
Comment 3 Veerapuram Varadhan 2005-03-15 20:44:41 UTC
Jon: Here are my findings....

The core of the problem is '\' character.  '\' and '/' are treated same in MS
Windows and so are .NET libraries (atleast IMHO).  So, essentially,
/home/foo/bar\file.txt == /home/foo/bar/file.txt in Windows but not in Linux.

The fix for this bug contains two parts.

Part 1:- PathToQuotedFileUri (): The path passed to this method as an argument
should be properly escaped before calling Path.GetFullPath() which screwes up
the '\' and '/' handling, according to Linux.

Fix for part 1:- see the attachment, "Part-1 fix".

Part 2:- FileInfo class:  This class also doesn't understand the difference
between '\' and '/' in Linux.  When, from FilteredIndexable.BuildFromFile(),
Filter.Open (new FileInfo (path)) gets called, the original path,
"/home/foo/bar\file.txt" gets converted to "/home/foo/bar/file.txt" and thus
generating the "FileNotFoundException".

Fix for part 2:- FileStream class can be used instead of FileInfo.  A basic
study on the usage of FileInfo in Filters reveal that only FullName and Length
properties of FileInfo class were being used.  FileStream also has Length and
Name properties that return same values that of FileInfo class.  However, a
small difference do exist between FileInfo.FullName and FileStream.Name,
FileStream.Name will not give "fully-qualified-path", but, beagle already
generates the fully-qualified-path before giving it to filters.  (see, Part-1,
PathToQuotedFileUri.
Comment 4 Veerapuram Varadhan 2005-03-16 12:38:17 UTC
Ok.  Enough investigation is done.  This seems to be a limitation in Mono.

Mono treats both '\' and '/' as path separators and which is the source of this bug.

I did a simple investigation in java using the following sample code, which
seems to work fine.

import java.io.*;
                                                                               
                                             
public class javapath {
    public static void main (String[] args)
    {
        File f = new File (args[0]);
        System.out.println ("getname: "+f.getName());
        System.out.println ("getpath: "+f.getPath());
        System.out.println ("getAbsolutePath: "+f.getAbsolutePath());
    }
}

and the output is..

varadhan@linux:~/tries> java javapath /home/varadhan/samples/beagle\'s\\\ test.txt
getname: beagle's\ test.txt
getpath: /home/varadhan/samples/beagle's\ test.txt
getAbsolutePath: /home/varadhan/samples/beagle's\ test.txt

----------------

FileStream class however, is able to handle these files properly, but only when
you "open" an existing file.


Will add more comments/findings later.
Comment 5 Veerapuram Varadhan 2005-03-16 20:55:41 UTC
This is a mono bug.  See http://bugzilla.ximian.com/show_bug.cgi?id=68566 and
http://bugzilla.ximian.com/show_bug.cgi?id=71214
Comment 6 Veerapuram Varadhan 2005-03-18 14:37:42 UTC
Created attachment 38903 [details] [review]
Handle '\' cases.
Comment 7 Veerapuram Varadhan 2005-03-18 14:37:51 UTC
Created attachment 38904 [details] [review]
Handle '\' cases properly and do not spew out exception traces.
Comment 8 Veerapuram Varadhan 2005-03-18 14:38:42 UTC
Comment on attachment 38903 [details] [review]
Handle '\' cases.

Handle '\' cases properly and do not spew out exception traces.
Comment 9 Daniel Drake 2005-03-19 00:53:41 UTC
Tested this, works fine as a workaround for me.
Comment 10 Christian Kirbach 2005-03-19 12:28:37 UTC
Thanks for sending in.
Raising priority to make maintainers aware of patch.
Adding PATCH keyword.
Comment 11 Veerapuram Varadhan 2005-03-31 13:52:14 UTC
*** Bug 172244 has been marked as a duplicate of this bug. ***
Comment 12 Jon Trowbridge 2005-04-05 05:47:56 UTC
Fixed in CVS.