summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp')
-rw-r--r--tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
index f5835ec5f4..bcf6d6c32b 100644
--- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
+++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
@@ -650,6 +650,31 @@ void tst_QUrlInternal::ace_testsuite_data()
<< "xn--djrptm67aikb.xn--kpry57d"
<< "."
<< taiwaneseIDN;
+
+ // violations / invalids
+ QTest::newRow("invalid-punycode") << "xn--z" << "xn--z" << "xn--z" << "xn--z";
+
+ // U+00A0 NO-BREAK SPACE encodes to Punycode "6a"
+ // but it is prohibited and should have caused encoding failure
+ QTest::newRow("invalid-nameprep-prohibited") << "xn--6a" << "xn--6a" << "xn--6a" << "xn--6a";
+
+ // U+00AD SOFT HYPHEN between "a" and "b" encodes to Punycode "ab-5da"
+ // but it should have been removed in the nameprep stage
+ QTest::newRow("invalid-nameprep-maptonothing") << "xn-ab-5da" << "xn-ab-5da" << "xn-ab-5da" << "xn-ab-5da";
+
+ // U+00C1 LATIN CAPITAL LETTER A WITH ACUTE encodes to Punycode "4ba"
+ // but it should have nameprepped to lowercase first
+ QTest::newRow("invalid-nameprep-uppercase") << "xn--4ba" << "xn--4ba" << "xn--4ba" << "xn--4ba";
+
+ // U+00B5 MICRO SIGN encodes to Punycode "sba"
+ // but is should have nameprepped to NFKC U+03BC GREEK SMALL LETTER MU
+ QTest::newRow("invalid-nameprep-nonnfkc") << "xn--sba" << "xn--sba" << "xn--sba" << "xn--sba";
+
+ // U+04CF CYRILLIC SMALL LETTER PALOCHKA encodes to "s5a"
+ // but it's not in RFC 3454's allowed character list (Unicode 3.2)
+ QTest::newRow("invalid-nameprep-unassigned") << "xn--s5a" << "xn--s5a" << "xn--s5a" << "xn--s5a";
+ // same character, see QTBUG-60364
+ QTest::newRow("invalid-nameprep-unassigned2") << "xn--80ak6aa92e" << "xn--80ak6aa92e" << "xn--80ak6aa92e" << "xn--80ak6aa92e";
}
void tst_QUrlInternal::ace_testsuite()
@@ -670,6 +695,14 @@ void tst_QUrlInternal::ace_testsuite()
QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + suffix);
QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + suffix);
+ QUrl u;
+ u.setHost(domain);
+ QVERIFY(u.isValid());
+ QCOMPARE(u.host(), unicode + suffix);
+ QCOMPARE(u.host(QUrl::EncodeUnicode), toace + suffix);
+ QCOMPARE(u.toEncoded(), "//" + toace.toLatin1() + suffix);
+ QCOMPARE(u.toDisplayString(), "//" + unicode + suffix);
+
domain = in + (suffix ? ".troll.No" : "");
QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + suffix);
if (fromace != ".")