summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-09-10 00:12:14 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-09-10 00:12:14 (GMT)
commit5c0d1ab1236b895e84d254ac6670c802e9162952 (patch)
tree18532f03e7cae7fb88b00d8b9d4d7514c50ea0ab /src/corelib
parent62c5bafeec64ef5a81a9011b4cf377b5d1d20653 (diff)
parentad35d25e78c8252a72108a4ba931934047c4707e (diff)
downloadQt-5c0d1ab1236b895e84d254ac6670c802e9162952.zip
Qt-5c0d1ab1236b895e84d254ac6670c802e9162952.tar.gz
Qt-5c0d1ab1236b895e84d254ac6670c802e9162952.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging: Merge fixes for QDir::operator== QSslCertificate: block all DigiNotar (intermediate and root) certs Restore Qt4.7 behaviour of QFileInfo::absolute(File)Path Fix compile error on MSVC2008 Fix comparison of absolute, unclean paths in QDir Wrap calls to Sequence::push_back
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/concurrent/qtconcurrentfilter.h20
-rw-r--r--src/corelib/concurrent/qtconcurrentfunctionwrappers.h19
-rw-r--r--src/corelib/concurrent/qtconcurrentmap.h8
-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
9 files changed, 81 insertions, 27 deletions
diff --git a/src/corelib/concurrent/qtconcurrentfilter.h b/src/corelib/concurrent/qtconcurrentfilter.h
index 4b9c4ae..d8c5f43 100644
--- a/src/corelib/concurrent/qtconcurrentfilter.h
+++ b/src/corelib/concurrent/qtconcurrentfilter.h
@@ -102,10 +102,9 @@ namespace QtConcurrent {
namespace QtConcurrent {
-template <typename Sequence, typename KeepFunctor, typename T, typename C, typename U>
-ThreadEngineStarter<void> filterInternal(Sequence &sequence, KeepFunctor keep, T (C::*reduce)(U))
+template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
+ThreadEngineStarter<void> filterInternal(Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce)
{
- typedef MemberFunctionWrapper1<T, C, U> ReduceFunctor;
typedef typename Sequence::const_iterator Iterator;
typedef FilterKernel<Sequence, KeepFunctor, ReduceFunctor> KernelType;
return startThreadEngine(new KernelType(sequence, keep, reduce));
@@ -115,7 +114,7 @@ ThreadEngineStarter<void> filterInternal(Sequence &sequence, KeepFunctor keep, T
template <typename Sequence, typename KeepFunctor>
QFuture<void> filter(Sequence &sequence, KeepFunctor keep)
{
- return filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back);
+ return filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::PushBackWrapper());
}
// filteredReduced() on sequences
@@ -184,7 +183,7 @@ QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin, Iter
template <typename Sequence, typename KeepFunctor>
void blockingFilter(Sequence &sequence, KeepFunctor keep)
{
- filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back).startBlocking();
+ filterInternal(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::PushBackWrapper()).startBlocking();
}
// blocking filteredReduced() on sequences
@@ -246,18 +245,17 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingFiltered
template <typename Sequence, typename KeepFunctor>
Sequence blockingFiltered(const Sequence &sequence, KeepFunctor keep)
{
- return blockingFilteredReduced(sequence, QtPrivate::createFunctionWrapper(keep), &Sequence::push_back, OrderedReduce);
+ return startFilteredReduced<Sequence>(sequence, QtPrivate::createFunctionWrapper(keep), QtPrivate::PushBackWrapper(), OrderedReduce).startBlocking();
}
// blocking filtered() on iterators
template <typename OutputSequence, typename Iterator, typename KeepFunctor>
OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep)
{
- return blockingFilteredReduced(begin,
- end,
- QtPrivate::createFunctionWrapper(keep),
- &OutputSequence::push_back,
- OrderedReduce);
+ return startFilteredReduced<OutputSequence>(begin, end,
+ QtPrivate::createFunctionWrapper(keep),
+ QtPrivate::PushBackWrapper(),
+ OrderedReduce).startBlocking();
}
} // namespace QtConcurrent
diff --git a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
index 4bf2736..1e09221 100644
--- a/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
+++ b/src/corelib/concurrent/qtconcurrentfunctionwrappers.h
@@ -195,6 +195,25 @@ QtConcurrent::ConstMemberFunctionWrapper<T, C> createFunctionWrapper(T (C::*func
return QtConcurrent::ConstMemberFunctionWrapper<T, C>(func);
}
+struct PushBackWrapper
+{
+ typedef void result_type;
+
+ template <class C, class U>
+ inline void operator()(C &c, const U &u) const
+ {
+ return c.push_back(u);
+ }
+
+#ifdef Q_COMPILER_RVALUE_REFS
+ template <class C, class U>
+ inline void operator()(C &c, U &&u) const
+ {
+ return c.push_back(u);
+ }
+#endif
+};
+
template <typename Functor, bool foo = HasResultType<Functor>::Value>
struct LazyResultType { typedef typename Functor::result_type Type; };
template <typename Functor>
diff --git a/src/corelib/concurrent/qtconcurrentmap.h b/src/corelib/concurrent/qtconcurrentmap.h
index 37a4143..166d5c8 100644
--- a/src/corelib/concurrent/qtconcurrentmap.h
+++ b/src/corelib/concurrent/qtconcurrentmap.h
@@ -271,7 +271,7 @@ OutputSequence blockingMapped(const InputSequence &sequence, MapFunctor map)
return blockingMappedReduced<OutputSequence>
(sequence,
QtPrivate::createFunctionWrapper(map),
- &OutputSequence::push_back,
+ QtPrivate::PushBackWrapper(),
QtConcurrent::OrderedReduce);
}
@@ -282,7 +282,7 @@ typename QtPrivate::MapResultType<InputSequence, MapFunctor>::ResultType blockin
return blockingMappedReduced<OutputSequence>
(sequence,
QtPrivate::createFunctionWrapper(map),
- &OutputSequence::push_back,
+ QtPrivate::PushBackWrapper(),
QtConcurrent::OrderedReduce);
}
@@ -293,7 +293,7 @@ Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor map)
return blockingMappedReduced<Sequence>
(begin, end,
QtPrivate::createFunctionWrapper(map),
- &Sequence::push_back,
+ QtPrivate::PushBackWrapper(),
QtConcurrent::OrderedReduce);
}
@@ -304,7 +304,7 @@ typename QtPrivate::MapResultType<Iterator, MapFunctor>::ResultType blockingMapp
return blockingMappedReduced<OutputSequence>
(begin, end,
QtPrivate::createFunctionWrapper(map),
- &OutputSequence::push_back,
+ QtPrivate::PushBackWrapper(),
QtConcurrent::OrderedReduce);
}
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;