summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qurl
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2013-09-08 15:16:26 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-11 01:26:07 +0200
commitaba336c2b4ad8926dc8a000718bbb7f8a6d5a72d (patch)
tree5ca738ded3609a8d5f39f1dac22e4c81023cccb8 /tests/auto/corelib/io/qurl
parent8fa0e4d1d202a3d1302469e6827c622423328383 (diff)
QUrl: ensure that setPath("//path") doesn't lead to scheme://path
which would interpret 'path' as a hostname. The check is in the public setPath so that the internal one can still support parsing URLs such as ftp://ftp.example.com//path. [ChangeLog][Important Behavior Changes][QUrl and QUrlQuery]QUrl now normalizes the path given in setPath, removing ./ and ../ and duplicate slashes. Change-Id: I05ccd8a1d813de45e460384239c059418a8e6a08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io/qurl')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 2fc0ea5c2a..e2fa0d3b47 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -3373,6 +3373,12 @@ void tst_QUrl::setComponents_data()
QTest::newRow("path-%3A-before-slash") << QUrl()
<< int(Path) << "c%3A/" << Tolerant << true
<< PrettyDecoded << "c%3A/" << "c%3A/";
+ QTest::newRow("path-doubleslash") << QUrl("trash:/")
+ << int(Path) << "//path" << Tolerant << true
+ << PrettyDecoded << "/path" << "trash:/path";
+ QTest::newRow("path-withdotdot") << QUrl("file:///tmp")
+ << int(Path) << "//tmp/..///root/." << Tolerant << true
+ << PrettyDecoded << "/root" << "file:///root";
// the other fields can be present and be empty
// that is, their delimiters would be present, but there would be nothing to one side
@@ -3642,6 +3648,8 @@ void tst_QUrl::setComponents()
if (isValid) {
QFETCH(QString, toString);
QCOMPARE(copy.toString(), toString);
+ // Check round-tripping
+ QCOMPARE(QUrl(copy.toString()).toString(), toString);
} else {
QVERIFY(copy.toString().isEmpty());
}