diff options
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r-- | src/corelib/io/qurl.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index f7269798a3..50512a4a73 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -413,7 +413,6 @@ #include "qstringlist.h" #include "qdebug.h" #include "qhash.h" -#include "qdir.h" // for QDir::fromNativeSeparators #include "qdatastream.h" #if QT_CONFIG(topleveldomain) // ### Qt6: Remove section #include "qtldurl_p.h" @@ -1267,10 +1266,16 @@ static const QChar *parseIp6(QString &host, const QChar *begin, const QChar *end zoneId = decoded.mid(zoneIdPosition + zoneIdIdentifier.size()); endBeforeZoneId = decoded.constBegin() + zoneIdPosition; + // was there anything after the zone ID separator? if (zoneId.isEmpty()) return end; } + // did the address become empty after removing the zone ID? + // (it might have always been empty) + if (decoded.constBegin() == endBeforeZoneId) + return end; + const QChar *ret = QIPAddressUtils::parseIp6(address, decoded.constBegin(), endBeforeZoneId); if (ret) return begin + (ret - decoded.constBegin()); @@ -3635,6 +3640,8 @@ bool QUrl::operator <(const QUrl &url) const /*! Returns \c true if this URL and the given \a url are equal; otherwise returns \c false. + + \sa matches() */ bool QUrl::operator ==(const QUrl &url) const { @@ -3742,6 +3749,8 @@ bool QUrl::matches(const QUrl &url, FormattingOptions options) const /*! Returns \c true if this URL and the given \a url are not equal; otherwise returns \c false. + + \sa matches() */ bool QUrl::operator !=(const QUrl &url) const { @@ -3810,6 +3819,25 @@ bool QUrl::isDetached() const return !d || d->ref.loadRelaxed() == 1; } +static QString fromNativeSeparators(const QString &pathName) +{ +#if defined(Q_OS_WIN) + QString result(pathName); + const QChar nativeSeparator = u'\\'; + auto i = result.indexOf(nativeSeparator); + if (i != -1) { + QChar * const data = result.data(); + const auto length = result.length(); + for (; i < length; ++i) { + if (data[i] == nativeSeparator) + data[i] = u'/'; + } + } + return result; +#else + return pathName; +#endif +} /*! Returns a QUrl representation of \a localFile, interpreted as a local @@ -3848,7 +3876,7 @@ QUrl QUrl::fromLocalFile(const QString &localFile) if (localFile.isEmpty()) return url; QString scheme = fileScheme(); - QString deslashified = QDir::fromNativeSeparators(localFile); + QString deslashified = fromNativeSeparators(localFile); // magic for drives on windows if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) { |