diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-07 15:52:44 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-08 11:29:22 (GMT) |
commit | a91a9d014adaeaa58640641579e30b5ff2383e99 (patch) | |
tree | 68b2c24a9be400b4b5a94367c1e865bc75699790 /src | |
parent | cb23007c0e04e8d23b426ca1a3672f70282012c7 (diff) | |
download | Qt-a91a9d014adaeaa58640641579e30b5ff2383e99.zip Qt-a91a9d014adaeaa58640641579e30b5ff2383e99.tar.gz Qt-a91a9d014adaeaa58640641579e30b5ff2383e99.tar.bz2 |
Fix handling of braces/no-braces in QUrl::host / setHost.
The hostname is supposed to be stored in canonical form, with the
braces. However, if you call url.setHost("::1"), then a non-canonical
hostname is stored. So make the canonicalisation function correct this.
Task-number: QTBUG-13464
Reviewed-by: Markus Goetz
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qurl.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 56a03c9..74c24b5 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3399,16 +3399,20 @@ QString QUrlPrivate::canonicalHost() const if (host.contains(QLatin1Char(':'))) { // This is an IP Literal, use _IPLiteral to validate QByteArray ba = host.toLatin1(); + bool needsBraces = false; if (!ba.startsWith('[')) { // surround the IP Literal with [ ] if it's not already done so ba.reserve(ba.length() + 2); ba.prepend('['); ba.append(']'); + needsBraces = true; } const char *ptr = ba.constData(); if (!_IPLiteral(&ptr)) that->host.clear(); + else if (needsBraces) + that->host = QString::fromLatin1(ba.toLower()); else that->host = host.toLower(); } else { |