summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-07-31 15:19:30 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-01 13:04:21 +0200
commit0838ac541d38b33b23955c036bbcfd94ccc19066 (patch)
tree8aec778ef4bc36a75247a84f3ee9ba498a13e875 /tests
parente1038794b1d7fe298535960eb90d5c823aa3f2c4 (diff)
Make sure that the parsing mode reaches QUrlPrivate::setHost
Ensure that the parsing mode is cascaded down from setAuthority and setUrl so that the hostname parsing does not attempt to decode percent-encoded hostnames when it shouldn't. Take the opportunity to also remove the "Boolean Trap" from QUrlPrivate::setHost. Change-Id: Ia64754c4a4900182700b7af1382aea8410abc7e9 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index acde1f8871..6b7a8025ff 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -1842,6 +1842,7 @@ void tst_QUrl::strictParser_data()
QTest::newRow("invalid-password") << "http://user:pass\x7F@ok-hostname" << "Invalid password";
QTest::newRow("invalid-regname") << "http://bad<hostname>" << "Hostname contains invalid characters";
+ QTest::newRow("invalid-regname-2") << "http://b%61d" << "Hostname contains invalid characters";
QTest::newRow("invalid-ipv6") << "http://[:::]" << "Invalid IPv6 address";
QTest::newRow("invalid-ipvfuture-1") << "http://[v7]" << "Invalid IPvFuture address";
QTest::newRow("invalid-ipvfuture-2") << "http://[v7.]" << "Invalid IPvFuture address";
@@ -2007,6 +2008,13 @@ void tst_QUrl::tolerantParser()
QVERIFY(url.isValid());
QCOMPARE(QString(url.toEncoded()), QString("http://strange%3Cusername%3E@hostname/"));
}
+
+ {
+ QUrl url;
+ url.setUrl("http://en%63o%64%65%64.hostname/", QUrl::TolerantMode);
+ QVERIFY(url.isValid());
+ QCOMPARE(url.toString(), QString("http://encoded.hostname/"));
+ }
}
void tst_QUrl::correctEncodedMistakes_data()
@@ -3045,6 +3053,15 @@ void tst_QUrl::setComponents_data()
QTest::newRow("invalid-host-1") << QUrl("http://example.com")
<< int(Host) << "-not-valid-" << Tolerant << false
<< PrettyDecoded << "" << "";
+ QTest::newRow("invalid-host-2") << QUrl("http://example.com")
+ << int(Host) << "%31%30.%30.%30.%31" << Strict << false
+ << PrettyDecoded << "" << "";
+ QTest::newRow("invalid-authority-1") << QUrl("http://example.com")
+ << int(Authority) << "-not-valid-" << Tolerant << false
+ << PrettyDecoded << "" << "";
+ QTest::newRow("invalid-authority-2") << QUrl("http://example.com")
+ << int(Authority) << "%31%30.%30.%30.%31" << Strict << false
+ << PrettyDecoded << "" << "";
QTest::newRow("invalid-path-1") << QUrl("/relative")
<< int(Path) << "c:/" << Strict << false
<< PrettyDecoded << "" << "";
@@ -3063,10 +3080,13 @@ void tst_QUrl::setComponents_data()
QTest::newRow("password-encode") << QUrl("http://example.com")
<< int(Password) << "h%61llo:world@" << Decoded << true
<< PrettyDecoded << "h%2561llo:world@" << "http://:h%2561llo:world%40@example.com";
- // '%' characters are not permitted in the hostname, this tests that it fails to set anything
+ // '%' characters are not permitted in the hostname, these test that it fails to set anything
QTest::newRow("invalid-host-encode") << QUrl("http://example.com")
<< int(Host) << "ex%61mple.com" << Decoded << false
<< PrettyDecoded << "" << "";
+ QTest::newRow("invalid-authority-encode") << QUrl("http://example.com")
+ << int(Authority) << "ex%61mple.com" << Decoded << false
+ << PrettyDecoded << "" << "";
QTest::newRow("path-encode") << QUrl("http://example.com/foo")
<< int(Path) << "bar%23" << Decoded << true
<< PrettyDecoded << "bar%2523" << "http://example.com/bar%2523";
@@ -3142,6 +3162,11 @@ void tst_QUrl::setComponents()
QCOMPARE(copy.host(QUrl::ComponentFormattingOptions(encoding)), output);
break;
+ case Authority:
+ copy.setAuthority(newValue, QUrl::ParsingMode(parsingMode));
+ QCOMPARE(copy.authority(QUrl::ComponentFormattingOptions(encoding)), output);
+ break;
+
case Query:
copy.setQuery(newValue, QUrl::ParsingMode(parsingMode));
QCOMPARE(copy.hasQuery(), !newValue.isNull());