Bug 159017

Summary: URLs are converted to lower case
Product: [Unmaintained] kdelibs Reporter: Christian Nitschkowski <christian.nitschkowski>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: mail
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Christian Nitschkowski 2008-03-09 15:13:19 UTC
Version:            (using KDE 4.0.2)
Installed from:    SuSE RPMs

When I open an URL with uppercase letters via KRunner, it will convert the whole URL to lowercase.
As there are servers which handle URLs case sensitively, this will lead to errors.
Opening an URL with uppercase letters in Konqueror works ok, by the way.
So this is a KRunner specific behaviour.
Comment 1 Sebastian Sauer 2008-03-09 23:04:41 UTC
Quit interesting case. The code in question is in http://websvn.kde.org/trunk/KDE/kdebase/workspace/plasma/runners/locations/locationrunner.cpp?view=markup

void processUrl(KUrl &url, const QString &term)
{
    if (url.protocol().isEmpty()) {
        int idx = term.indexOf('/');
        url.clear();
        url.setProtocol("http");
        url.setHost(term.left(idx));
        if (idx != -1) {
            url.setPath(term.mid(idx));
        }
    }
}

Here the testcases;

KUrl u1("www.Abc.de");
kDebug()<<u1.url(); //"www.Abc.de"
u1.setProtocol("http");
kDebug()<<u1.url(); //"http://www.abc.de"

KUrl u2;
u2.setProtocol("http");
u2.setHost("www.Abc.de");
kDebug()<<u2.url(); //"http://www.abc.de"

KUrl u3;
u3.setScheme("http");
u3.setHost("www.Abc.de");
kDebug()<<u3.url(); //"http://www.abc.de"

The case;

iirc a few yearsago we had a discussion if the hostname is really always lowercased. While iirc the w3c-spec says yes, this is false cause there are quit some protocols like donkey and magnet that use the hostname for a filename-reference and therefore _need_ to be case-sensitive.

That time somehow we came to the conclusion that KUrl isn't only about url's as the RFC define them and therefore KUrl got patched to be able to deal with the hostname in a case-sensitive way by Petter E. Stokke.

Now the situation is, that we adopted QUrl, our code got removed and we are again case-insensitive :-/

The result;

I've no idea there and iirc the patch by Petter was rather big and not easy to understand :-(
Comment 2 Sebastian Sauer 2008-03-09 23:06:24 UTC
eh, a small typo went in. The first testcase should be;

KUrl u1("www.Abc.de"); 
kDebug()<<u1.url(); //"www.Abc.de" 
u1.setProtocol("http"); 
kDebug()<<u1.url(); //"http:www.Abc.de" (so, without "//" but uppercased)
Comment 3 Christian Nitschkowski 2008-03-09 23:35:58 UTC
Doesn't that mean that konqueror uses something different than KURL/QUrl?
As I wrote in the report when I enter the address in konqueror directly, it works case sensitively as expected.
Comment 4 Sebastian Sauer 2008-03-09 23:56:36 UTC
It does for you? Well, with current trunk if I put "www.Abc.de" in, Konqueror changes it to "http://www.abc.de".
Comment 5 Sebastian Sauer 2008-03-09 23:57:40 UTC
change product from krunner to kdelibs since it's a KUrl/QUrl related thing rather then KRunner.
Comment 6 Sebastian Sauer 2008-03-10 00:17:04 UTC
re-thinking about comment #3 and comment #4 ;
afair there went quit some patches and more unittests in for KUrl in trunk. So, it may possible that a bug was fixed in trunk to let both behave the same now.
Comment 7 David Faure 2008-03-10 15:51:32 UTC
SVN commit 784049 by dfaure:

The hostname becomes lowercase indeed, both in stable and trunk, and both with http and with other protocols. Just like in kde3.
CCBUG: 159017


 M  +17 -0     kurltest.cpp  
 M  +1 -0      kurltest.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=784049
Comment 8 David Faure 2008-03-10 15:55:03 UTC
I think there's some confusion in this report. Christian is talking about krunner bug which would convert the _whole_ URL to lowercase, while Sebastian (and my kurl unit tests) are about the hostname being converted to lowercase.
So let's go back to the original issue: if I type http://www.ABC.de/FR in krunner then I get http://www.abc.de/fr in konqueror. And that's not a KUrl issue.
Comment 9 David Faure 2008-03-10 15:55:48 UTC
SVN commit 784052 by dfaure:

only the hostname becomes lowercase, not the path.
CCBUG: 159017


 M  +4 -2      kurltest.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=784052
Comment 10 David Faure 2008-03-10 16:12:03 UTC
SVN commit 784055 by dfaure:

not all urls and paths are lowercase
BUG: 159017


 M  +1 -1      locationrunner.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=784055
Comment 11 Sebastian Sauer 2008-03-10 19:17:49 UTC
re kurltest; the protocol is named "ed2k" rather then "donkey" (sorry for that confusion, but the test wouldn't work anyway since it needs KMLDonkey to be installed).

just for the records since imho as long as nobody does complain... (I don't plan to port the KMLDonkey kio-slave to KDE4 anyway ;)
* in 2003 the thread at kde-devel that was dealing with that issue was http://66.92.20.25/?t=105978281800002&r=1&w=2
* the bugreport was bug #62425
Comment 12 David Faure 2008-03-10 20:32:01 UTC
On Monday 10 March 2008, Sebastian Sauer wrote:
> the protocol is named "ed2k" rather then "donkey" (sorry for that confusion, but the test wouldn't work anyway since it needs KMLDonkey to be installed


The test would work in all cases; this is a KUrl test, it does not depend on what software you have installed.
Comment 13 Sebastian Sauer 2008-03-10 22:48:09 UTC
hmmmm, then I got probably really something totaly wrong.

The KDE3 KUrl solution did use those [Protocol] desktop-files and evaluated there the URIMode to differ between URL and raw mode. But the testcases all test only the URL mode.

So, with URL-mode;
KUrl("ed2k:/SomeString/OtherString") => "ed2k:/somestring/OtherString"

With RAW-mode;
KUrl("ed2k:/SomeString/OtherString") => "ed2k:/SomeString/OtherString"

ed2k (aka donkey), magnet and sig2dat are all raw-mode aka URIMode=rawuri
http://websvn.kde.org/branches/extragear/kde3/network/kmldonkey/scripts/ed2k.protocol?view=markup
http://websvn.kde.org/branches/extragear/kde3/network/kmldonkey/scripts/magnet.protocol?view=markup
http://websvn.kde.org/branches/extragear/kde3/network/kmldonkey/scripts/sig2dat.protocol?view=markup
Comment 14 Sebastian Sauer 2008-03-10 22:56:07 UTC
eh, again a small fix (an additional "/" since SomeString is the hostname);
URL; KUrl("ed2k://SomeString/OtherString") => "ed2k://somestring/OtherString" 
RAW; KUrl("ed2k://SomeString/OtherString") => "ed2k://SomeString/OtherString" 
Comment 15 David Faure 2008-03-11 16:56:07 UTC
You're right, KDE3's KURL used those protocol files.
But I considered this a nasty hack (it also led to awful dependencies).
A better solution has to be found in QUrl (and not discussed in this unrelated bug report). Please reopen 62425 or open a new one, and include thiago in the discussion.