summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp10
2 files changed, 11 insertions, 1 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index f975fb4e43..3e711b12ec 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -777,7 +777,7 @@ void QUrlPrivate::setUserInfo(const QString &userInfo, int from, int end)
int delimIndex = userInfo.indexOf(QLatin1Char(':'), from);
setUserName(userInfo, from, qMin<uint>(delimIndex, end));
- if (delimIndex == -1) {
+ if (uint(delimIndex) >= uint(end)) {
password.clear();
sectionIsPresent &= ~Password;
sectionHasError &= ~Password;
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 46d491ba79..63f9cd06dc 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -411,6 +411,16 @@ void tst_QUrl::setUrl()
}
{
+ QUrl url("http://user@localhost:8000/xmlhttprequest/resources/basic-auth-nouserpass/basic-auth-nouserpass.php");
+ QVERIFY(url.isValid());
+ QCOMPARE(url.scheme(), QString::fromLatin1("http"));
+ QCOMPARE(url.userName(), QString::fromLatin1("user"));
+ QCOMPARE(url.password(), QString());
+ QCOMPARE(url.userInfo(), QString::fromLatin1("user"));
+ QCOMPARE(url.port(), 8000);
+ }
+
+ {
QUrl url("http://www.foo.bar");
QVERIFY(url.isValid());