summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/io/qfilesystemengine_symbian.cpp4
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp6
-rw-r--r--tests/auto/qfileinfo/tst_qfileinfo.cpp10
4 files changed, 12 insertions, 10 deletions
diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp
index 18c52cb..c8c1dfd 100644
--- a/src/corelib/io/qfilesystemengine_symbian.cpp
+++ b/src/corelib/io/qfilesystemengine_symbian.cpp
@@ -114,9 +114,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
{
QString orig = entry.filePath();
const bool isAbsolute = entry.isAbsolute();
- const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) ||
- orig.contains(QLatin1String("//")) ||
- orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/.")));
+ const bool isDirty = !entry.isClean();
if (isAbsolute && !isDirty)
return entry;
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index b0ebfbd..cfb17de 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -223,7 +223,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
//static
QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
{
- if (entry.isAbsolute())
+ if (entry.isAbsolute() && entry.isClean())
return entry;
QByteArray orig = entry.nativeFilePath();
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 764ee6d..031d64b 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -508,11 +508,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
if (!entry.isRelative()) {
#if !defined(Q_OS_WINCE)
- if (entry.isAbsolute()
- && !entry.filePath().contains(QLatin1String("/../"))
- && !entry.filePath().contains(QLatin1String("/./"))
- && !entry.filePath().endsWith(QLatin1String("/.."))
- && !entry.filePath().endsWith(QLatin1String("/."))) {
+ if (entry.isAbsolute() && entry.isClean()) {
ret = entry.filePath();
} else {
ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath()));
diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp
index 4e4b92d..d7d57f6 100644
--- a/tests/auto/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp
@@ -482,6 +482,11 @@ void tst_QFileInfo::absolutePath_data()
QTest::newRow("c:\\autoexec.bat") << "c:\\autoexec.bat" << "C:/"
<< "autoexec.bat";
#endif
+ QTest::newRow("QTBUG-19995.1") << drivePrefix + "/System/Library/StartupItems/../Frameworks"
+ << drivePrefix + "/System/Library"
+ << "Frameworks";
+ QTest::newRow("QTBUG-19995.2") << drivePrefix + "/System/Library/StartupItems/../Frameworks/"
+ << drivePrefix + "/System/Library/Frameworks" << "";
}
void tst_QFileInfo::absolutePath()
@@ -503,6 +508,7 @@ void tst_QFileInfo::absFilePath_data()
QTest::newRow("relativeFile") << "tmp.txt" << QDir::currentPath() + "/tmp.txt";
QTest::newRow("relativeFileInSubDir") << "temp/tmp.txt" << QDir::currentPath() + "/" + "temp/tmp.txt";
+ QString drivePrefix;
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
QString curr = QDir::currentPath();
@@ -511,7 +517,7 @@ void tst_QFileInfo::absFilePath_data()
QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "C:/home/andy/tmp.txt";
// Make sure drive-relative paths return correct absolute paths (task 255326)
- QString drivePrefix = QDir::currentPath().left(2);
+ drivePrefix = QDir::currentPath().left(2);
QString nonCurrentDrivePrefix =
drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:");
@@ -521,6 +527,8 @@ void tst_QFileInfo::absFilePath_data()
#else
QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "/home/andy/tmp.txt";
#endif
+ QTest::newRow("QTBUG-19995") << drivePrefix + "/System/Library/StartupItems/../Frameworks"
+ << drivePrefix + "/System/Library/Frameworks";
}
void tst_QFileInfo::absFilePath()