diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-07-08 15:30:45 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-12-12 07:25:22 +0000 |
commit | 101449a4cfa9c0d216332c6dc8ba826e8109e09d (patch) | |
tree | 9a5494bdc1c1819d837a97e74fc220f85e4e8310 /tests | |
parent | f7b44f879cdded7b2c6b604df873f7194e56a63a (diff) |
QDir::cd(): Handle UNC server paths correctly
Add a bool *ok out parameter to qt_normalizePathSegments() and return false
when ".." are left over for an absolute path, indicating an attempt to
change above root.
Factor out static helper qt_cleanPath() to be able to pass the return value
to QDir::cd() and return on failure from there.
Amends change 63f634322b2c0f795bd424be9e51953a10c701de, which did
not handle UNC paths.
Task-number: QTBUG-53712
Change-Id: I3e63a5dd0259306a0b99145348d815899582f78e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qdir/tst_qdir.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index fe12850476..b86c6e4dfa 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -58,7 +58,8 @@ #ifdef QT_BUILD_INTERNAL QT_BEGIN_NAMESPACE -extern Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &, bool); +extern Q_AUTOTEST_EXPORT QString + qt_normalizePathSegments(const QString &path, bool allowUncPaths, bool *ok = nullptr); QT_END_NAMESPACE #endif @@ -2246,6 +2247,10 @@ void tst_QDir::cdBelowRoot_data() const QString systemRoot = QString::fromLocal8Bit(qgetenv("SystemRoot")); QTest::newRow("windows-drive") << systemDrive << systemRoot.mid(3) << QDir::cleanPath(systemRoot); + const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); + const QString testDirectory = QStringLiteral("testshare"); + QTest::newRow("windows-share") + << uncRoot << testDirectory << QDir::cleanPath(uncRoot + QLatin1Char('/') + testDirectory); #endif // Windows } |