Bug in KURL handling(?)

Ingo Klöcker kloecker at kde.org
Tue Dec 14 19:58:07 GMT 2004


On Tuesday 14 December 2004 13:31, Thiago Macieira wrote:
> Andras Mantia wrote:
> >Ok, I see. I think this is a point where the fact that Konqueror is
> > both a file manager and a browser is not the best thing. In a
> > browser one expects that every path is converted to a file:/// URL,
> > and this way anchors work there (just try Firefox for example),
> > while in a file manager one would expect that a file is accessed.
> > Whatever, thankfully people usually don't type such entries in the
> >location bar too often.
>
> If you type in the Location bar:
>  /home/user/filename#anchor
>
> Konqueror should display:
>  file:///home/user/filename%23anchor
>
> And probably report a problem that the file cannot be found. That
> way, the person will know after the first attempt what is going on.
>
> The current behaviour is not acceptable, in which it displays # in
> the Location bar both for anchors and for %23. Could this be a
> problem with KURL::prettyURL() ?

It's a problem with StripFileProtocol. The leading "file://" must only 
be stripped off if the URL contains only a path. A file URL which has a 
reference must not be stripped. Otherwise browsing locally stored docs 
like KDE's API documentation doesn't work anymore because the 
file /home/ingo/cvs/kde/3.3/compiled/apidocs/kdecore/html/classKURL.html#_details 
doesn't exist. Doh!

Proposed fix:
Index: kurl.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kurl.cpp,v
retrieving revision 1.285
diff -u -3 -p -r1.285 kurl.cpp
--- kurl.cpp    3 Dec 2004 13:18:56 -0000       1.285
+++ kurl.cpp    14 Dec 2004 19:54:06 -0000
@@ -1576,7 +1576,7 @@ QString KURL::prettyURL( int _trailing )
 QString KURL::prettyURL( int _trailing, AdjustementFlags _flags) const
 {
        QString u = prettyURL(_trailing);
-       if (_flags & StripFileProtocol && u.startsWith("file://")) {
+       if (_flags & StripFileProtocol && u.startsWith("file://") && !hasRef()) {
                u.remove(0, 7);
 #ifdef Q_WS_WIN
                return QDir::convertSeparators(u);

I'm not using KDE HEAD, so I can't test it. Can file-URLs have a query? 
If yes, then this should probably also be checked.

Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20041214/e188913f/attachment.sig>


More information about the kde-core-devel mailing list