summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2011-09-19 04:12:35 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2011-09-19 04:12:35 (GMT)
commit5055f13683dd0670d62a81e61bf097fd220f0d42 (patch)
tree1cf10d701b6d6ba5fffe9a2267ecf894d505e1bd /src/corelib/io
parentfc602cb1737e58b4b814c4a799fa2a68acb6dbcd (diff)
parent53d9e3620ede7492c141402d9365d5c0dd7c10fd (diff)
downloadQt-5055f13683dd0670d62a81e61bf097fd220f0d42.zip
Qt-5055f13683dd0670d62a81e61bf097fd220f0d42.tar.gz
Qt-5055f13683dd0670d62a81e61bf097fd220f0d42.tar.bz2
Merge remote branch 'origin/4.8' into doc-staging-master
Conflicts: dist/changes-4.8.0
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qdir.cpp17
-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--src/corelib/io/qfilesystementry.cpp31
-rw-r--r--src/corelib/io/qfilesystementry_p.h1
-rw-r--r--src/corelib/io/qsettings.cpp14
7 files changed, 53 insertions, 22 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index d9086c1..4ba8e06 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -198,7 +198,7 @@ inline void QDirPrivate::resolveAbsoluteEntry() const
QString absoluteName;
if (fileEngine.isNull()) {
- if (!dirEntry.isRelative()) {
+ if (!dirEntry.isRelative() && dirEntry.isClean()) {
absoluteDirEntry = dirEntry;
return;
}
@@ -1638,8 +1638,19 @@ bool QDir::operator==(const QDir &dir) const
if (d->dirEntry.filePath() == other->dirEntry.filePath())
return true;
- // Fallback to expensive canonical path computation
- return canonicalPath().compare(dir.canonicalPath(), sensitive) == 0;
+ if (exists()) {
+ if (!dir.exists())
+ return false; //can't be equal if only one exists
+ // Both exist, fallback to expensive canonical path computation
+ return canonicalPath().compare(dir.canonicalPath(), sensitive) == 0;
+ } else {
+ if (dir.exists())
+ return false; //can't be equal if only one exists
+ // Neither exists, compare absolute paths rather than canonical (which would be empty strings)
+ d->resolveAbsoluteEntry();
+ other->resolveAbsoluteEntry();
+ return d->absoluteDirEntry.filePath().compare(other->absoluteDirEntry.filePath(), sensitive) == 0;
+ }
}
return false;
}
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/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index bb7cb4e..2f37542 100644
--- a/src/corelib/io/qfilesystementry.cpp
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -380,4 +380,35 @@ void QFileSystemEntry::findFileNameSeparators() const
}
}
+bool QFileSystemEntry::isClean() const
+{
+ resolveFilePath();
+ int dots = 0;
+ bool dotok = true; // checking for ".." or "." starts to relative paths
+ bool slashok = true;
+ for (QString::const_iterator iter = m_filePath.constBegin(); iter != m_filePath.constEnd(); iter++) {
+ if (*iter == QLatin1Char('/')) {
+ if (dots == 1 || dots == 2)
+ return false; // path contains "./" or "../"
+ if (!slashok)
+ return false; // path contains "//"
+ dots = 0;
+ dotok = true;
+ slashok = false;
+ } else if (dotok) {
+ slashok = true;
+ if (*iter == QLatin1Char('.')) {
+ dots++;
+ if (dots > 2)
+ dotok = false;
+ } else {
+ //path element contains a character other than '.', it's clean
+ dots = 0;
+ dotok = false;
+ }
+ }
+ }
+ return (dots != 1 && dots != 2); // clean if path doesn't end in . or ..
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h
index 34b083a..8d524c0 100644
--- a/src/corelib/io/qfilesystementry_p.h
+++ b/src/corelib/io/qfilesystementry_p.h
@@ -91,6 +91,7 @@ public:
QString completeSuffix() const;
bool isAbsolute() const;
bool isRelative() const;
+ bool isClean() const;
#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
bool isDriveRoot() const;
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 79b2728..547bbeb 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -66,13 +66,12 @@
#ifndef QT_NO_QOBJECT
#include "qcoreapplication.h"
+#endif
#ifdef Q_OS_WIN // for homedirpath reading from registry
#include "qt_windows.h"
#include <private/qsystemlibrary_p.h>
-
-#endif // Q_OS_WIN
-#endif // QT_NO_QOBJECT
+#endif
#ifdef Q_OS_VXWORKS
# include <ioLib.h>
@@ -1024,9 +1023,6 @@ static QString windowsConfigPath(int type)
{
QString result;
-#ifndef QT_NO_QOBJECT
- // We can't use QLibrary if there is QT_NO_QOBJECT is defined
- // This only happens when bootstrapping qmake.
#ifndef Q_OS_WINCE
QSystemLibrary library(QLatin1String("shell32"));
#else
@@ -1040,8 +1036,6 @@ static QString windowsConfigPath(int type)
result = QString::fromWCharArray(path);
}
-#endif // QT_NO_QOBJECT
-
if (result.isEmpty()) {
switch (type) {
#ifndef Q_OS_WINCE
@@ -1114,11 +1108,11 @@ static void initDefaultPaths(QMutexLocker *locker)
userPath += QLatin1String(".config");
#endif
} else if (*env == '/') {
- userPath = QLatin1String(env);
+ userPath = QFile::decodeName(env);
} else {
userPath = homePath;
userPath += QLatin1Char('/');
- userPath += QLatin1String(env);
+ userPath += QFile::decodeName(env);
}
userPath += QLatin1Char('/');