diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-09-20 16:30:48 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-02 22:34:42 +0200 |
commit | 4f52a9509995b1f5c834354ff6d02fa9b4f4396d (patch) | |
tree | b01d4ced4273f7a9f64e88b93e5f6847196cefa7 | |
parent | 7b696e4ec72bff9a606658e70258fcdba55c6cd0 (diff) |
Update some error messages in QUrl::errorString()
Make both invalid hostname messages start with "Invalid hostname". And
split the empty port error from the invalid port one.
Change-Id: I870d1ed6fb07ec494f553871a37ed167141ffc06
Reviewed-by: David Faure <faure@kde.org>
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
-rw-r--r-- | src/corelib/io/qurl.cpp | 5 | ||||
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 20 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index b7339a202e..92f613d4c3 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3545,7 +3545,7 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, QChar c) return QString(QStringLiteral("Invalid hostname (character '%1' not permitted)")) .arg(c); else - return QStringLiteral("Hostname contains invalid characters"); + return QStringLiteral("Invalid hostname (contains invalid characters)"); case QUrlPrivate::InvalidIPv4AddressError: return QString(); // doesn't happen yet case QUrlPrivate::InvalidIPv6AddressError: @@ -3556,8 +3556,9 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, QChar c) return QStringLiteral("Expected ']' to match '[' in hostname"); case QUrlPrivate::InvalidPortError: - case QUrlPrivate::PortEmptyError: return QStringLiteral("Invalid port or port number out of range"); + case QUrlPrivate::PortEmptyError: + return QStringLiteral("Port field was empty"); case QUrlPrivate::InvalidPathError: return QString(QStringLiteral("Invalid path (character '%1' not permitted)")) diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 03bc64e753..25ff3155bc 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1626,6 +1626,7 @@ void tst_QUrl::ipv6() if (url.isValid()) { QCOMPARE(url.toString(), output); url.setHost(url.host()); + QVERIFY(url.isValid()); QCOMPARE(url.toString(), output); } } @@ -1759,7 +1760,8 @@ void tst_QUrl::isValid() url.setAuthority("strange;hostname"); QVERIFY(!url.isValid()); QVERIFY(url.toString().isEmpty()); - QVERIFY(url.errorString().contains("Hostname contains invalid characters")); + QVERIFY2(url.errorString().contains("Invalid hostname"), + qPrintable(url.errorString())); } { @@ -1776,7 +1778,7 @@ void tst_QUrl::isValid() url.setHost("stuff;1"); QVERIFY(!url.isValid()); QVERIFY(url.toString().isEmpty()); - QVERIFY2(url.errorString().contains("Hostname contains invalid characters"), + QVERIFY2(url.errorString().contains("Invalid hostname"), qPrintable(url.errorString())); } @@ -1897,15 +1899,17 @@ void tst_QUrl::strictParser_data() QTest::newRow("invalid-password") << "http://user:pass\x7F@ok-hostname" << "Invalid password"; - QTest::newRow("invalid-regname") << "http://bad<hostname>" << "Hostname contains invalid characters"; - QTest::newRow("invalid-regname-2") << "http://b%61d" << "Hostname contains invalid characters"; + QTest::newRow("invalid-regname") << "http://bad<hostname>" << "Invalid hostname"; + QTest::newRow("invalid-regname-2") << "http://b%61d" << "Invalid hostname"; QTest::newRow("invalid-ipv6") << "http://[:::]" << "Invalid IPv6 address"; QTest::newRow("invalid-ipvfuture-1") << "http://[v7]" << "Invalid IPvFuture address"; QTest::newRow("invalid-ipvfuture-2") << "http://[v7.]" << "Invalid IPvFuture address"; QTest::newRow("invalid-ipvfuture-3") << "http://[v789]" << "Invalid IPvFuture address"; QTest::newRow("unbalanced-brackets") << "http://[ff02::1" << "Expected ']'"; - QTest::newRow("empty-port") << "http://example.com:" << "Invalid port"; + // port errors happen in TolerantMode too + QTest::newRow("empty-port-1") << "http://example.com:" << "empty"; + QTest::newRow("empty-port-2") << "http://example.com:/" << "empty"; QTest::newRow("invalid-port-1") << "http://example.com:-1" << "Invalid port"; QTest::newRow("invalid-port-2") << "http://example.com:abc" << "Invalid port"; QTest::newRow("invalid-port-3") << "http://example.com:9a" << "Invalid port"; @@ -1927,9 +1931,9 @@ void tst_QUrl::strictParser() QVERIFY(!url.isValid()); QVERIFY(url.toString().isEmpty()); QVERIFY(!url.errorString().isEmpty()); - if (!url.errorString().contains(needle)) - qWarning("Error string changed and does not contain \"%s\" anymore: %s", - qPrintable(needle), qPrintable(url.errorString())); + QVERIFY2(url.errorString().contains(needle), + "Error string changed and does not contain \"" + + needle.toLatin1() + "\" anymore: " + url.errorString().toLatin1()); } void tst_QUrl::tolerantParser() |