Disallow spaces in URLs when parsing in StrictMode.
Change-Id: I16de68aff2b9e84cc800734c5875aaee9a2ea565 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
329ee8cedc
commit
64a10879cb
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user