summaryrefslogtreecommitdiffstats
path: root/tests/auto/qurl/tst_qurl.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-09-07 17:00:10 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-09-10 08:53:31 (GMT)
commitecac806359a092e2e09adb027e5a45d2cd993a9f (patch)
tree26ed050ebed52f6fddb73477b845d91332cb3170 /tests/auto/qurl/tst_qurl.cpp
parent16aeed255560b5e9479efe9b74517fb647922694 (diff)
downloadQt-ecac806359a092e2e09adb027e5a45d2cd993a9f.zip
Qt-ecac806359a092e2e09adb027e5a45d2cd993a9f.tar.gz
Qt-ecac806359a092e2e09adb027e5a45d2cd993a9f.tar.bz2
Update the error handling of invalid hostnames in QUrl.
This should let QUrl::errorString() show the original, invalid hostname in the URL it reports to be invalid. There may be a side-effect that QUrl::toEncoded() may include the broken hostname on the first call, then miss it in the next calls. But since QUrl::isValid() is returning false, we can consider that the result of toEncoded() is undefined, so anything goes. Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests/auto/qurl/tst_qurl.cpp')
-rw-r--r--tests/auto/qurl/tst_qurl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index b5236e5..63f9721 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -2478,16 +2478,26 @@ void tst_QUrl::isValid()
QUrl url = QUrl::fromEncoded("http://strange;hostname/here");
QVERIFY(!url.isValid());
QCOMPARE(url.path(), QString("/here"));
+ url.setAuthority("strange;hostname");
+ QVERIFY(!url.isValid());
url.setAuthority("foobar@bar");
QVERIFY(url.isValid());
+ url.setAuthority("strange;hostname");
+ QVERIFY(!url.isValid());
+ QVERIFY(url.errorString().contains("invalid hostname"));
}
{
QUrl url = QUrl::fromEncoded("foo://stuff;1/g");
QVERIFY(!url.isValid());
QCOMPARE(url.path(), QString("/g"));
+ url.setHost("stuff;1");
+ QVERIFY(!url.isValid());
url.setHost("stuff-1");
QVERIFY(url.isValid());
+ url.setHost("stuff;1");
+ QVERIFY(!url.isValid());
+ QVERIFY(url.errorString().contains("invalid hostname"));
}
}