Bug 171562 - JJ: KUrl corrupts IPv6 address
Summary: JJ: KUrl corrupts IPv6 address
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 4.2.2
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
: 195651 195929 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-09-24 00:53 UTC by Wieger Hofstra
Modified: 2009-06-15 16:20 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch kurl.cpp add brackets if host contains a colon (414 bytes, patch)
2009-06-11 06:15 UTC, Wieger Hofstra
Details
patch kurltest.cpp Add an ipv6 address testcase for pretty url (629 bytes, patch)
2009-06-11 06:18 UTC, Wieger Hofstra
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wieger Hofstra 2008-09-24 00:53:40 UTC
Version:            (using KDE 4.1.1)
OS:                Linux
Installed from:    Ubuntu Packages

When you go to: http://[IPv6 address]/ konqueror loads the page correctly.
However after loading, konqueror changes the address string to: http://IPv6 address/ (the [] are gone). This makes it not possible to reload the page without editing the address.
Comment 1 Julian Bäume 2009-01-13 17:35:49 UTC
This still happens for me. I'm using latest Factory-packages from openSUSE. (Version 4.1.87).

This is only a problem with IPv6 ip addresses, IPv6 Internet over DNS works just fine. (So ipv6.google.com just works nice)
Comment 2 Julian Bäume 2009-01-13 17:39:13 UTC
And another thing to mention: this happens not only with http(s), but also all other protocols like fish:// and so on.
Comment 3 Julian Bäume 2009-03-07 02:21:46 UTC
Hi,

I found out, this happens because of KUrl::prettyUrl() not printing out "[]" for IPv6 addresses. It uses the QUrl::host() method to determine the host-part of the URL. For IPv6 addresses this is without the brackets. KUrl::prettyUrl() should add these brackets, I think. According to RFC4038 the square brackets should be added, if the address occurs in conjunction to a TCP port number (which is also separated by a colon) or something similar. It also states, that parsers should not force users to use these brackets. QUrl does, if I tested that right and so KUrl::prettyUrl() should _allways_ add the square brackets to an IPv6 address. This behaviour would be okay, as all parsers should be able to parse IPv6 addresses including square brackets, also they are not in conjunction with any colons that belong to other data, than the address itself.

To check if a given string represents a valid IPv6 address isn't this easy. There is a regexp, which is quite long. ;) So I thought of a shorter way to fix this issue. I mentioned, that QUrl::host() seems to only return valid hosts. I think, hostnames can never contain colons, only IPv6 addresses can. So  QUrl::host().contains(":") should be a valid check for that.
If we can use contains(":"), this fix should be easy. Otherwise the regexp needs to be used as a valid check.

bye then
julian
Comment 4 Dario Andres 2009-06-10 21:24:00 UTC
*** Bug 195651 has been marked as a duplicate of this bug. ***
Comment 5 Dario Andres 2009-06-10 21:24:10 UTC
*** Bug 195929 has been marked as a duplicate of this bug. ***
Comment 6 Malte S. Stretz 2009-06-10 21:31:34 UTC
So this is a kdelibs bug, reassigning.
Comment 7 Malte S. Stretz 2009-06-10 21:33:34 UTC
Marking as JJ, a fix with Julian's proposal (which should be enough to fix this) should be trivial.
Comment 8 Wieger Hofstra 2009-06-11 06:15:44 UTC
Created attachment 34421 [details]
patch kurl.cpp add brackets if host contains a colon

Guess this should be enough
Comment 9 Wieger Hofstra 2009-06-11 06:18:14 UTC
Created attachment 34422 [details]
patch kurltest.cpp Add an ipv6 address testcase for pretty url
Comment 10 David Faure 2009-06-15 16:20:17 UTC
SVN commit 982329 by dfaure:

Apply patch from Wieger Hofstra to fix IPV6 in prettyUrl() - thanks!
(patch slightly modified for performance)
BUG: 171562


 M  +6 -1      io/kurl.cpp  
 M  +4 -0      tests/kurltest.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=982329