summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-07-31 14:28:48 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-01 13:04:18 +0200
commite1038794b1d7fe298535960eb90d5c823aa3f2c4 (patch)
tree02f152e85fc942fa17239db3c5c4ac0ebe5d8651 /tests
parentf893d9ec41578c0981507dccc41d1ee2a11f6bae (diff)
Make QUrl::setScheme only parse in strict mode (no decoding)
The URI RFC defines schemes as containing only a very restricted set of characters, none of which require encoding, so don't even try. Testing this behaviour in some web browsers indicate that they do not accept percent-encoded schemes either. Change-Id: I692dd20e1aac7e8a1bcb276cb5113b5802393d38 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 8b4908f977..acde1f8871 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -1833,9 +1833,8 @@ void tst_QUrl::strictParser_data()
QTest::addColumn<QString>("input");
QTest::addColumn<QString>("needle");
- // cannot test bad schemes here, as they are parsed as paths instead
- //QTest::newRow("invalid-scheme") << "ht%://example.com" << "Invalid scheme";
- //QTest::newRow("empty-scheme") << ":/" << "Empty scheme";
+ QTest::newRow("invalid-scheme") << "ht%://example.com" << "Invalid scheme";
+ QTest::newRow("empty-scheme") << ":/" << "Empty scheme";
QTest::newRow("invalid-user1") << "http://bad<user_name>@ok-hostname" << "Invalid user name";
QTest::newRow("invalid-user2") << "http://bad%@ok-hostname" << "Invalid user name";
@@ -1870,6 +1869,7 @@ void tst_QUrl::strictParser()
QFETCH(QString, needle);
QUrl url(input, QUrl::StrictMode);
+ QEXPECT_FAIL("empty-scheme", "QUrl does not forbid paths with a colon before the first slash yet", Abort);
QVERIFY(!url.isValid());
QVERIFY(!url.errorString().isEmpty());
if (!url.errorString().contains(needle))
@@ -3038,6 +3038,9 @@ void tst_QUrl::setComponents_data()
QTest::newRow("invalid-scheme-2") << QUrl("http://example.com")
<< int(Scheme) << "http%40" << Tolerant << false
<< PrettyDecoded << "" << "";
+ QTest::newRow("invalid-scheme-3") << QUrl("http://example.com")
+ << int(Scheme) << "http%61" << Strict << false
+ << PrettyDecoded << "" << "";
QTest::newRow("invalid-host-1") << QUrl("http://example.com")
<< int(Host) << "-not-valid-" << Tolerant << false
@@ -3047,6 +3050,10 @@ void tst_QUrl::setComponents_data()
<< PrettyDecoded << "" << "";
// -- test decoded behaviour --
+ // '%' characters are not permitted in the scheme, this tests that it fails to set anything
+ QTest::newRow("invalid-scheme-encode") << QUrl("http://example.com")
+ << int(Scheme) << "http%61" << Decoded << false
+ << PrettyDecoded << "" << "";
QTest::newRow("userinfo-encode") << QUrl("http://example.com")
<< int(UserInfo) << "h%61llo:world@" << Decoded << true
<< PrettyDecoded << "h%2561llo:world@" << "http://h%2561llo:world%40@example.com";
@@ -3104,6 +3111,7 @@ void tst_QUrl::setComponents()
switch (component) {
case Scheme:
+ // scheme is only parsed in strict mode
copy.setScheme(newValue);
QCOMPARE(copy.scheme(), output);
break;