summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-01-22 14:00:27 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-01-22 14:04:20 (GMT)
commit670f90b3068d530f14000eb816dd9ff38f9fb005 (patch)
treebc52714bce75cf01e7ccecbddae6643fdbcc4a3c
parentdf01c399c0d9f3412c872ad9ccb7342af0a44ea2 (diff)
downloadQt-670f90b3068d530f14000eb816dd9ff38f9fb005.zip
Qt-670f90b3068d530f14000eb816dd9ff38f9fb005.tar.gz
Qt-670f90b3068d530f14000eb816dd9ff38f9fb005.tar.bz2
Autotest: add a test for allowing hostnames ending in dot
Also, since domain is never empty, the idx > 0 test is unnecessary.
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--tests/auto/qurl/tst_qurl.cpp22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index ba1110d..076cc33 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3242,7 +3242,7 @@ static QString qt_ACE_do(const QString &domain, AceOperation op)
int idx = nextDotDelimiter(domain, lastIdx);
int labelLength = idx - lastIdx;
if (labelLength == 0) {
- if (idx == domain.length() && idx > 0)
+ if (idx == domain.length())
break;
return QString(); // two delimiters in a row -- empty label not allowed
}
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 33812fe..f108f4c 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -165,6 +165,8 @@ private slots:
void ace_testsuite();
void std3violations_data();
void std3violations();
+ void std3deviations_data();
+ void std3deviations();
void tldRestrictions_data();
void tldRestrictions();
void emptyQueryOrFragment();
@@ -3238,6 +3240,8 @@ void tst_QUrl::std3violations_data()
QTest::newRow("bang") << "foo!" << false;
QTest::newRow("plus") << "foo+bar" << false;
QTest::newRow("dot") << "foo.bar";
+ QTest::newRow("startingdot") << ".bar" << false;
+ QTest::newRow("startingdot2") << ".example.com" << false;
QTest::newRow("slash") << "foo/bar" << true;
QTest::newRow("colon") << "foo:80" << true;
QTest::newRow("question") << "foo?bar" << true;
@@ -3282,6 +3286,24 @@ void tst_QUrl::std3violations()
QVERIFY(!url.isValid());
}
+void tst_QUrl::std3deviations_data()
+{
+ QTest::addColumn<QString>("source");
+
+ QTest::newRow("ending-dot") << "example.com.";
+ QTest::newRow("ending-dot3002") << QString("example.com") + QChar(0x3002);
+}
+
+void tst_QUrl::std3deviations()
+{
+ QFETCH(QString, source);
+ QVERIFY(!QUrl::toAce(source).isEmpty());
+
+ QUrl url;
+ url.setHost(source);
+ QVERIFY(!url.host().isEmpty());
+}
+
void tst_QUrl::tldRestrictions_data()
{
QTest::addColumn<QString>("tld");