tst_qurlinternal: Add tests for punycode overflow

Add two tests for decoding IDNs when they encode values outside Unicode
(> 0x110000).

"xn--5p32g" decodes to "a" (all ASCII) before QTBUG-95577 got fixed.

"xn--400595c" decodes to the same value as "xn--097c" after the above
mentioned bug got fixed. This test is currently failing.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: Icab55c41e0233b34d57e38232fa90ac42f35a50a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Ievgenii Meshcheriakov 2021-08-09 18:34:57 +02:00
parent 9bd2ab85ac
commit 62b5d88b0d

View File

@ -675,6 +675,17 @@ void tst_QUrlInternal::ace_testsuite_data()
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";
// Decodes to "a" in some versions, see QTBUG-95689
QTest::newRow("punycode-overflow-1") << "xn--5p32g"
<< "xn--5p32g"
<< "xn--5p32g"
<< "xn--5p32g";
// Decodes to the same string as "xn--097c" in some versions, see QTBUG-95689
QTest::newRow("punycode-overflow-2") << "xn--400595c"
<< "xn--400595c"
<< "xn--400595c"
<< "xn--400595c";
}
void tst_QUrlInternal::ace_testsuite()
@ -691,6 +702,8 @@ void tst_QUrlInternal::ace_testsuite()
QString domain = in + suffix;
QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + suffix);
QEXPECT_FAIL("punycode-overflow-2", "QTBUG-95689: Missing oweflow check in punycode decoder",
Abort);
if (fromace != ".")
QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + suffix);
QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + suffix);