diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-01-15 14:49:32 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-17 18:13:42 +0100 |
commit | 83b1eaad44862828b3248840c33f16e0b73df479 (patch) | |
tree | fc613c93c1ea24e5c4fb477a98f6c1abd14721a1 /src/corelib/io/qurl.cpp | |
parent | ba56beaea41620647c15a9f6b79cd7756c46698a (diff) |
Make a URL with absent authority be different from one with an empty one
This partially reverts 5764f5e6eaf149116a818658883cf4fae9830f30 and
fixes the problem differently.
After this commit, "file:///foo" is still equal to "file:/foo", but
"foo:///foo" becomes different from "foo:/foo", as it should be.
Task-number: QTBUG-36151
Change-Id: Ia38638b0f30a7dcf110aa89aa427254c007fc107
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r-- | src/corelib/io/qurl.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index f17215964f..7018b333f2 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3542,9 +3542,13 @@ bool QUrl::operator ==(const QUrl &url) const if (!url.d) return d->isEmpty(); - // Compare which sections are present, but ignore Host - // which is set by parsing but not by construction, when empty. - const int mask = QUrlPrivate::FullUrl & ~QUrlPrivate::Host; + // First, compare which sections are present, since it speeds up the + // processing considerably. We just have to ignore the host-is-present flag + // for local files (the "file" protocol), due to the requirements of the + // XDG file URI specification. + int mask = QUrlPrivate::FullUrl; + if (isLocalFile()) + mask &= ~QUrlPrivate::Host; return (d->sectionIsPresent & mask) == (url.d->sectionIsPresent & mask) && d->scheme == url.d->scheme && d->userName == url.d->userName && @@ -3575,9 +3579,13 @@ bool QUrl::matches(const QUrl &url, FormattingOptions options) const if (!url.d) return d->isEmpty(); - // Compare which sections are present, but ignore Host - // which is set by parsing but not by construction, when empty. - int mask = QUrlPrivate::FullUrl & ~QUrlPrivate::Host; + // First, compare which sections are present, since it speeds up the + // processing considerably. We just have to ignore the host-is-present flag + // for local files (the "file" protocol), due to the requirements of the + // XDG file URI specification. + int mask = QUrlPrivate::FullUrl; + if (isLocalFile()) + mask &= ~QUrlPrivate::Host; if (options & QUrl::RemoveScheme) mask &= ~QUrlPrivate::Scheme; |