diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-09-02 17:40:45 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-09-05 10:46:09 (GMT) |
commit | ef774ee93cb561d072137f2a11c2d347bedf6342 (patch) | |
tree | f5b492964bc7b913430c7fabd8e57bb063c3bc7b /src/corelib | |
parent | 4a6617b83612d79c8557102c9d313c28aee2aa0e (diff) | |
download | Qt-ef774ee93cb561d072137f2a11c2d347bedf6342.zip Qt-ef774ee93cb561d072137f2a11c2d347bedf6342.tar.gz Qt-ef774ee93cb561d072137f2a11c2d347bedf6342.tar.bz2 |
Restore Qt4.7 behaviour of QFileInfo::absolute(File)Path
Many applications relied on the undefined behaviour that the
filesystem engines returned clean paths (despite the documentation
stating that they may not), and consequently suffered regressions with
Qt 4.8.
Unix paths are once again cleaned if necessary.
Windows/Symbian paths were already cleaned, but now use the utility
function to check if a path is dirty, to avoid duplicated code.
Task-number: QTBUG-19995
Change-Id: If8c18469f149291c9d079ae3da23bc2087bbd49a
Reviewed-on: http://codereview.qt.nokia.com/4154
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Prasanth Ullattil <prasanth.ullattil@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qfilesystemengine_symbian.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 6 |
3 files changed, 3 insertions, 9 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())); |