diff options
author | Shane Kearns <ext-shane.2.kearns@nokia.com> | 2012-04-20 16:34:34 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-23 12:12:19 (GMT) |
commit | d1c8e6deda97b014a817b703f48189e436b415f5 (patch) | |
tree | f1cfb9da6815950605b28db22717212240b71741 | |
parent | b5149bec53e6eb3b2baa4bfb95eeaf0bfb9bd67b (diff) | |
download | Qt-d1c8e6deda97b014a817b703f48189e436b415f5.zip Qt-d1c8e6deda97b014a817b703f48189e436b415f5.tar.gz Qt-d1c8e6deda97b014a817b703f48189e436b415f5.tar.bz2 |
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>
-rw-r--r-- | src/corelib/io/qurl.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 51631ff..8e3f111 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; } /*! |