diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-09-01 14:04:33 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-09-02 12:38:57 (GMT) |
commit | ddf5a09d469a1ded5490cffe54e0013a0d5ba347 (patch) | |
tree | 656e7a7abaacd551f554bf2326dba20276eb194d /tests/auto/qfilesystementry | |
parent | ca34cc75294e0d2a8bc491a2c679fe8a69cd0408 (diff) | |
download | Qt-ddf5a09d469a1ded5490cffe54e0013a0d5ba347.zip Qt-ddf5a09d469a1ded5490cffe54e0013a0d5ba347.tar.gz Qt-ddf5a09d469a1ded5490cffe54e0013a0d5ba347.tar.bz2 |
Fix comparison of absolute, unclean paths in QDir
QDir::operator== was creating a clean absolute path for comparison
purposes if the original path was relative.
However original absolute paths were trusted, even though they could
be unclean. Now they are checked for cleanliness first.
Task-Number: QTBUG-19995
Task-Number: QTBUG-20495
Change-Id: I047a1a40ae5151e4604085e4ac87f30a4e4979c4
Reviewed-on: http://codereview.qt.nokia.com/4099
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Prasanth Ullattil <prasanth.ullattil@nokia.com>
Diffstat (limited to 'tests/auto/qfilesystementry')
-rw-r--r-- | tests/auto/qfilesystementry/tst_qfilesystementry.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 016bcbf..2daabee 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -68,6 +68,8 @@ private slots: void absoluteOrRelative_data(); void absoluteOrRelative(); #endif + void isClean_data(); + void isClean(); }; #if defined(WIN_STUFF) @@ -383,5 +385,35 @@ void tst_QFileSystemEntry::absoluteOrRelative() } #endif +void tst_QFileSystemEntry::isClean_data() +{ + QTest::addColumn<QString>("path"); + QTest::addColumn<bool>("isClean"); + + QTest::newRow("simple") << "foo" << true; + QTest::newRow("complex") << "/foo/bar/bz" << true; + QTest::newRow(".file") << "/foo/.file" << true; + QTest::newRow("..file") << "/foo/..file" << true; + QTest::newRow("...") << "/foo/.../bar" << true; + QTest::newRow("./") << "./" << false; + QTest::newRow("../") << "../" << false; + QTest::newRow(".") << "." << false; + QTest::newRow("..") << ".." << false; + QTest::newRow("/.") << "/." << false; + QTest::newRow("/..") << "/.." << false; + QTest::newRow("/../") << "foo/../bar" << false; + QTest::newRow("/./") << "foo/./bar" << false; + QTest::newRow("//") << "foo//bar" << false; +} + +void tst_QFileSystemEntry::isClean() +{ + QFETCH(QString, path); + QFETCH(bool, isClean); + + QFileSystemEntry fi(path); + QCOMPARE(fi.isClean(), isClean); +} + QTEST_MAIN(tst_QFileSystemEntry) #include <tst_qfilesystementry.moc> |