summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-04-20 17:34:34 +0100
committerQt by Nokia <qt-info@nokia.com>2012-04-23 14:12:19 +0200
commitd1c8e6deda97b014a817b703f48189e436b415f5 (patch)
treef1cfb9da6815950605b28db22717212240b71741 /src/corelib
parentb5149bec53e6eb3b2baa4bfb95eeaf0bfb9bd67b (diff)
Fix IPv6 address returned from QUrl::host
When passing an IPv6 address through QNetworkProxyQuery, it is stored in a QUrl internally. There was a bug in QUrl where it strips the [] surrounding an IPv6 address only if they were present in the input, otherwise it added them. Now the behaviour is the same as Qt5 ([] are always stripped). Change-Id: I42e020ce30d18a4108f1dd4428809fed07991680 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qurl.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 51631ff859..8e3f111655 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -4755,11 +4755,10 @@ QString QUrl::host() const
if (!d) return QString();
if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse();
- if (d->host.isEmpty() || d->host.at(0) != QLatin1Char('['))
- return d->canonicalHost();
- QString tmp = d->host.mid(1);
- tmp.truncate(tmp.length() - 1);
- return tmp;
+ QString result = d->canonicalHost();
+ if (result.startsWith(QLatin1Char('[')))
+ return result.mid(1, result.length() - 2);
+ return result;
}
/*!