From 8e9a6aca959336ef150021a858178fc3cd1ad426 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 18 Mar 2009 20:57:48 +0100 Subject: Autotest: remove or correct invalid tests In making QUrl more strict with hostnames (to avoid malicious attacks), I'm implementing the STD3 checks described by RFC 3490. These tests are invalid, so they are being removed or corrected. STD3 requires that the hostname be composed of Letters, Digits, Hyphens (so no underlines) and limited to 63 characters. Also, an empty port doesn't make sense. --- tests/auto/qurl/tst_qurl.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 47c86cc..ea551da 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -608,18 +608,6 @@ void tst_QUrl::setUrl() } { - QString bigStr(QLatin1String("abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ")); - QUrl url; - url.setHost(bigStr); - QVERIFY(url.isValid()); - QCOMPARE(url.host().toLower(), bigStr.toLower()); - } - - { QUrl url; url.setUrl("hello.com#?"); QVERIFY(url.isValid()); @@ -1398,8 +1386,6 @@ void tst_QUrl::i18n_data() QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); - QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") - << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); QTest::newRow("räksmörgås") << QString::fromLatin1("http://www.räksmörgås.no/") << QByteArray("http://www.xn--rksmrgs-5wao1o.no/"); QTest::newRow("bühler") << QString::fromLatin1("http://www.bühler.no/") @@ -2423,19 +2409,18 @@ void tst_QUrl::isValid() QCOMPARE(url.path(), QString("A=B")); } { - QUrl url = QUrl::fromEncoded("http://strange@ok_hostname/", QUrl::StrictMode); + QUrl url = QUrl::fromEncoded("http://strange@ok-hostname/", QUrl::StrictMode); QVERIFY(!url.isValid()); // < and > are not allowed in userinfo in strict mode } { - QUrl url = QUrl::fromEncoded("http://strange@ok_hostname/"); + QUrl url = QUrl::fromEncoded("http://strange@ok-hostname/"); QVERIFY(url.isValid()); // < and > are allowed in tolerant mode } { QUrl url = QUrl::fromEncoded("http://strange;hostname/here"); - QVERIFY(url.isValid()); - QCOMPARE(url.host(), QString("strange;hostname")); + QVERIFY(!url.isValid()); QCOMPARE(url.path(), QString("/here")); } } @@ -3486,7 +3471,6 @@ void tst_QUrl::setAuthority_data() QTest::addColumn("authority"); QTest::addColumn("url"); QTest::newRow("Plain auth") << QString("62.70.27.22:21") << QString("//62.70.27.22:21"); - QTest::newRow("Auth with empty port") << QString("62.70.27.22:") << QString("//62.70.27.22:"); QTest::newRow("Yet another plain auth") << QString("192.168.1.1:21") << QString("//192.168.1.1:21"); QTest::newRow("Auth without port") << QString("192.168.1.1") << QString("//192.168.1.1"); QTest::newRow("Auth w/full hostname without port") << QString("shusaku.troll.no") << QString("//shusaku.troll.no"); @@ -3494,7 +3478,6 @@ void tst_QUrl::setAuthority_data() QTest::newRow("Auth w/full hostname that ends with number, without port") << QString("shusaku.troll.no.2") << QString("//shusaku.troll.no.2"); QTest::newRow("Auth w/hostname that ends with number, without port") << QString("shusaku2") << QString("//shusaku2"); QTest::newRow("Empty auth") << QString() << QString(); - QTest::newRow("Single") << QString(":") << QString("//:"); } void tst_QUrl::setAuthority() -- cgit v0.12