Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.2
-
None
-
caa598c843eb27fd0c645e62723fd2d4e3e12f60 (qt/qtbase/dev)
Description
QUrl::matches() behaves incorrect when using one of the formatting options QUrl::RemovePort, QUrl::RemoveUserInfo or QUrl::RemovePassword.
For example, when using QUrl::RemovePort, the comparison of the host is disabled. This leads to the following expression unexpectedly returning true:
QUrl("http://example.com").matches(QUrl("http://foobar.com"), QUrl::RemovePort)
The reason is the incorrect checking of the formatting option flags in QUrl::matches():
qurl.cpp, lines 3667-3670
if (options & QUrl::RemoveUserInfo) mask &= ~QUrlPrivate::UserName; else if (d->userName != url.d->userName) return false;
and
qurl.cpp, lines 3677-3680
if (options & QUrl::RemoveAuthority) mask &= ~QUrlPrivate::Host; else if (d->host != url.d->host) return false;
It should probably look like this:
if ( (options & QUrl::RemoveUserInfo) == QUrl::RemoveUserInfo) mask &= ~QUrlPrivate::UserName; else if (d->userName != url.d->userName) return false;
and
if ( (options & QUrl::RemoveAuthority) == QUrl::RemoveAuthority) mask &= ~QUrlPrivate::Host; else if (d->host != url.d->host) return false;
See also QUrl::adjusted() where the checks are done like that.
Attachments
For Gerrit Dashboard: QTBUG-70774 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
241328,3 | Fix QUrl::matches for when removing authority parts (other than host) | 5.11 | qt/qtbase | Status: MERGED | +2 | 0 |