Bug 121806

Summary: special characters in file names reported by slocate are not converted to valid urls
Product: [Applications] kfind Reporter: Georg Hennig <georg298>
Component: generalAssignee: Eric Coquelle <coquelle>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: fixes the bug for kde 3.5.1

Description Georg Hennig 2006-02-12 01:17:52 UTC
Version:            (using KDE KDE 3.5.1)
Installed from:    Compiled From Sources
OS:                Linux

Problem:
- have a file name containing a special character like "#" or even worse "/"
- have it in your current slocate db (updatedb)
- search the directory with kfind where the file is inside using the file index (slocate)
- the kfind result contains this file with invalid url

Example:
"test#%20asdf" is reported as "test" with 0 bytes file size and 0 modification time (=1.1.1970).

This comes from incorrect usage of KURL in kquery.cpp
KURLs are created directly from the slocate search result (which shows the special characters, e.g. "#").
For example KURL( "/path/to/test#asdf" ) is an invalid url.
It should rather be KURL::fromPathOrURL( "/path/to/test#asdf" ).

Quotation from KURL reference:

KURL KURL::fromPathOrURL ( const QString & text )[static]

Creates a KURL object from a QString representing either an absolute path or a real URL.

Use this method instead of

 QString someDir = ...
 KURL url = someDir;

Otherwise some characters (e.g. the '#') won't be encoded properly.
Comment 1 Georg Hennig 2006-02-12 01:19:10 UTC
Created attachment 14648 [details]
fixes the bug for kde 3.5.1

the problem doesn't seem to be solved on current svn.
Comment 2 Martin Koller 2006-11-25 23:04:34 UTC
SVN commit 607835 by mkoller:

BUG: 121806

fix KURL usage with filenames including special chars
Patch provided by Georg Hennig


 M  +1 -1      kquery.cpp  


--- branches/KDE/3.5/kdebase/kfind/kquery.cpp #607834:607835
@@ -153,7 +153,7 @@
 
   for (; it != end; ++it)
   {
-    file = new KFileItem( KFileItem::Unknown,  KFileItem::Unknown, KURL(*it));
+    file = new KFileItem( KFileItem::Unknown,  KFileItem::Unknown, KURL::fromPathOrURL(*it));
     processQuery(file);
     delete file;
   }