Fix QUrl support for empty usernames and passwords
If the password is empty (but present), the userinfo component of the
URL should end in a colon (":"). QUrl already supported that and it
was tested (case "password-empty").
If the username is *also* empty but present, the userinfo component is
just the colon (":"). Fix support for that case by checking if we
stored the presence flag instead of checking the size of the
component.
Change-Id: Ie224493a997dbf76b2e44dd6d55fd9674ac83c1c
Reviewed-by: David Faure <faure@kde.org>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
bb10
parent
4d1f0ccbf3
commit
f893d9ec41
|
|
@ -563,7 +563,7 @@ inline void QUrlPrivate::appendAuthority(QString &appendTo, QUrl::FormattingOpti
|
|||
|
||||
inline void QUrlPrivate::appendUserInfo(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const
|
||||
{
|
||||
if (Q_LIKELY(userName.isEmpty() && password.isEmpty()))
|
||||
if (Q_LIKELY(!hasUserInfo()))
|
||||
return;
|
||||
|
||||
const ushort *userNameActions;
|
||||
|
|
|
|||
|
|
@ -2991,15 +2991,21 @@ void tst_QUrl::setComponents_data()
|
|||
QTest::newRow("userinfo-empty") << QUrl("http://user:pass@example.com")
|
||||
<< int(UserInfo) << "" << Tolerant << true
|
||||
<< PrettyDecoded << "" << "http://@example.com";
|
||||
QTest::newRow("userinfo-colon") << QUrl("http://user@example.com")
|
||||
<< int(UserInfo) << ":" << Tolerant << true
|
||||
<< PrettyDecoded << ":" << "http://:@example.com";
|
||||
QTest::newRow("username-null") << QUrl("http://user@example.com")
|
||||
<< int(UserName) << QString() << Tolerant << true
|
||||
<< PrettyDecoded << QString() << "http://example.com";
|
||||
QTest::newRow("username-empty") << QUrl("http://user@example.com")
|
||||
<< int(UserName) << "" << Tolerant << true
|
||||
<< PrettyDecoded << "" << "http://@example.com";
|
||||
QTest::newRow("username-empty-path-nonempty") << QUrl("http://user:pass@example.com")
|
||||
<< int(UserName) << "" << Tolerant << true
|
||||
<< PrettyDecoded << "" << "http://:pass@example.com";
|
||||
QTest::newRow("username-empty-password-nonempty") << QUrl("http://user:pass@example.com")
|
||||
<< int(UserName) << "" << Tolerant << true
|
||||
<< PrettyDecoded << "" << "http://:pass@example.com";
|
||||
QTest::newRow("username-empty-password-empty") << QUrl("http://user:@example.com")
|
||||
<< int(UserName) << "" << Tolerant << true
|
||||
<< PrettyDecoded << "" << "http://:@example.com";
|
||||
QTest::newRow("password-null") << QUrl("http://user:pass@example.com")
|
||||
<< int(Password) << QString() << Tolerant << true
|
||||
<< PrettyDecoded << QString() << "http://user@example.com";
|
||||
|
|
|
|||
Loading…
Reference in New Issue