diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-04-23 23:03:58 -0300 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-04-25 00:51:43 +0000 |
commit | 9e2c6899e0a07edf525945a182d2537086441268 (patch) | |
tree | ea549a51c2b4da7f606df13e01ec03574aed6cc7 /tests | |
parent | e7222c0a71bf9b4fdd3bd660984dfa1045013514 (diff) |
QUrl: fix IDN conversion when the ACE form is invalid
We guarded against the Unicode form being invalid and did not produce an
encoded form. But we did not guard against proper Punycode sequences
that decode to forms that had not passed the proper Nameprep stage. So
check for that and, if it fails, just keep the label in the form we
found it in (it's valid STD3 anyway).
[ChangeLog][QtCore][QUrl] Fixed a bug that caused certain domain names
that look like Internationalized Domain Names to become corrupt in
decoded forms of QUrl, notably toString() and toDisplayString().
Task-number: QTBUG-60364
Change-Id: Iadfecb6f28984634979dfffd14b833142cca8d0d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index 766338e4f8..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() |