summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-01-08 14:34:46 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-14 20:45:48 (GMT)
commita17fc85b51a6bdcfa33dcff183d2b7efd667fb92 (patch)
tree099e837b8fd6375f2be2f2fa49db77078116fb72 /tests
parent6db96677ab9e1b3d717e3704a658e528b457b255 (diff)
downloadQt-a17fc85b51a6bdcfa33dcff183d2b7efd667fb92.zip
Qt-a17fc85b51a6bdcfa33dcff183d2b7efd667fb92.tar.gz
Qt-a17fc85b51a6bdcfa33dcff183d2b7efd667fb92.tar.bz2
Limit the range of the QUrlPrivate::port to -1 to 65535
The internal parser can read values outside this range (and cannot report an error), but QUrl::port() must not return something outside that range. The correct solution would be to report an error, like in Qt 5, but that cannot easily be done. The rewritten parser in Qt 5 is not affected by this issue. Task-number: QTBUG-28985 Change-Id: I3cf595384f14272197dcfb85943213c8f8ddeba0 Reviewed-by: David Faure (KDE) <faure@kde.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qurl/tst_qurl.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 64c579c..64d8bda 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -692,6 +692,16 @@ void tst_QUrl::setUrl()
QCOMPARE(url.encodedPath().constData(), "text/javascript,d5%20%3D%20'five%5Cu0027s'%3B");
}
+ {
+ // invalid port number
+ QUrl url;
+ url.setEncodedUrl("foo://tel:2147483648");
+ QVERIFY(url.isValid()); // ### should be !isValid(), but the parser can't catch it
+ QCOMPARE(url.scheme(), QString("foo"));
+ QCOMPARE(url.host(), QString("tel"));
+ QCOMPARE(url.port(), -1);
+ }
+
{ //check it calls detach
QUrl u1("http://aaa.com");
QUrl u2 = u1;
@@ -3935,6 +3945,7 @@ void tst_QUrl::fromUserInput_data()
QTest::newRow("trash-0") << "example.org/test?someData=42%&someOtherData=abcde#anchor" << QUrl::fromEncoded("http://example.org/test?someData=42%25&someOtherData=abcde#anchor");
QTest::newRow("other-scheme-0") << "spotify:track:0hO542doVbfGDAGQULMORT" << QUrl("spotify:track:0hO542doVbfGDAGQULMORT");
QTest::newRow("other-scheme-1") << "weirdscheme:80:otherstuff" << QUrl("weirdscheme:80:otherstuff");
+ QTest::newRow("number-path-0") << "tel:2147483648" << QUrl("tel:2147483648");
// FYI: The scheme in the resulting url user
QUrl authUrl("user:pass@domain.com");