Bug 121806 - special characters in file names reported by slocate are not converted to valid urls
Summary: special characters in file names reported by slocate are not converted to val...
Status: RESOLVED FIXED
Alias: None
Product: kfind
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Eric Coquelle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-12 01:17 UTC by Georg Hennig
Modified: 2006-11-25 23:04 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
fixes the bug for kde 3.5.1 (442 bytes, patch)
2006-02-12 01:19 UTC, Georg Hennig
Details

Note You need to log in before you can comment on or make changes to this bug.
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;
   }