diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-07-28 19:50:27 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-08-16 19:34:52 +0000 |
commit | b0479aab297f041aa9842c3e1996d62c16d7dbcf (patch) | |
tree | 7a24c4a150bba291b10335c4fce9cf2d9cad46a4 /tests | |
parent | 04bbf534f98387073ce327eac2718e0170f8d8c0 (diff) |
QUrl: Make sure we do reject URLs for which IDNA nameprep failed
qt_nameprep() already reset the string to its original length to
indicate failure, but we didn't handle that in qt_ACE_do(). So make it
have a return value whcih makes it easier to handle that case and do
handle it.
[ChangeLog][QtCore][QUrl] Fixed a bug that caused URLs whose hostnames
contained unassigned or prohibited Unicode codepoints to report
isValid() = true, despite clearing the hostname.
Change-Id: I41e7b3bced5944239f41fffd1545b7274c4b419d
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 20282068cb..09aefcee91 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -2048,6 +2048,21 @@ void tst_QUrl::isValid() } { + QUrl url = QUrl::fromEncoded("foo://%f0%9f%93%99.example.la/g"); + QVERIFY(!url.isValid()); + QVERIFY(url.toString().isEmpty()); + QCOMPARE(url.path(), QString("/g")); + url.setHost("%f0%9f%93%99.example.la/"); + QVERIFY(!url.isValid()); + QVERIFY(url.toString().isEmpty()); + url.setHost("\xf0\x9f\x93\x99.example.la/"); + QVERIFY(!url.isValid()); + QVERIFY(url.toString().isEmpty()); + QVERIFY2(url.errorString().contains("Invalid hostname"), + qPrintable(url.errorString())); + } + + { QUrl url("http://example.com"); QVERIFY(url.isValid()); QVERIFY(!url.toString().isEmpty()); @@ -2778,7 +2793,9 @@ void tst_QUrl::hosts() { QFETCH(QString, url); - QTEST(QUrl(url).host(), "host"); + QUrl u(url); + QTEST(u.host(), "host"); + QVERIFY(u.isEmpty() || u.isValid()); } void tst_QUrl::hostFlags_data() |