From d1c8e6deda97b014a817b703f48189e436b415f5 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 20 Apr 2012 17:34:34 +0100 Subject: 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 --- src/corelib/io/qurl.cpp | 9 ++++----- 1 file 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; } /*! -- cgit v0.12