summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2011-12-28 16:02:44 -0200
committerQt by Nokia <qt-info@nokia.com>2012-03-30 01:19:59 +0200
commit64a10879cb1f3a48b4b44c2e3a46694efb3bec0a (patch)
treea2dd0a08607d64b8a4fe175ab589a7fd07eff563
parent329ee8cedc78de5304a84e0b205b08f39e439411 (diff)
Disallow spaces in URLs when parsing in StrictMode.
Change-Id: I16de68aff2b9e84cc800734c5875aaee9a2ea565 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp4
2 files changed, 2 insertions, 4 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index d9413ef40c..a83d6ebea4 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -1047,7 +1047,7 @@ void QUrlPrivate::parse(const QString &url, QUrl::ParsingMode parsingMode)
continue;
if ((uc == '%' && (uint(len) < i + 2 || !isHex(data[i + 1]) || !isHex(data[i + 2])))
- || uc < 0x20 || strchr(forbidden, uc)) {
+ || uc <= 0x20 || strchr(forbidden, uc)) {
// found an error
errorSupplement = uc;
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 7e06dd4e88..5c9e20b9b4 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -1769,15 +1769,13 @@ void tst_QUrl::tolerantParser()
QCOMPARE(url.toString(QUrl::FullyEncoded), QString("http://www.example.com/path%20with%20spaces.html"));
url.setUrl("http://www.example.com/path%20with spaces.html", QUrl::StrictMode);
QVERIFY(!url.isValid());
- QCOMPARE(url.toString(QUrl::FullyEncoded), QString("http://www.example.com/path%20with%20spaces.html"));
}
{
QUrl url = QUrl::fromEncoded("http://www.example.com/path%20with spaces.html");
QVERIFY(url.isValid());
QCOMPARE(url.path(), QString("/path with spaces.html"));
url.setEncodedUrl("http://www.example.com/path%20with spaces.html", QUrl::StrictMode);
- QVERIFY(url.isValid());
- QCOMPARE(url.toString(QUrl::FullyEncoded), QString("http://www.example.com/path%20with%20spaces.html"));
+ QVERIFY(!url.isValid());
}
{