summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystementry.cpp
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/qfilesystementry.cpp
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/qfilesystementry.cpp')
-rw-r--r--src/corelib/io/qfilesystementry.cpp31
1 files changed, 31 insertions, 0 deletions
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