[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [baloo/Plasma/5.1] src/file: Escape dots in exclude filters
From: Dominik Cermak <d.cermak () arcor ! de>
Date: 2014-10-15 12:05:43
Message-ID: E1XeNKp-0001Xh-Vo () scm ! kde ! org
[Download RAW message or body]
Git commit 863ccc6f7901528338efabfef78098fc72cbd94f by Dominik Cermak.
Committed on 14/10/2014 at 11:36.
Pushed by cermak into branch 'Plasma/5.1'.
Escape dots in exclude filters
In regular expressions a dot (.) matches any character (except newline)
but in the exclude filters we use wildcard syntax (*) and want a dot (.)
to be interpreted as a character.
Example: With "*.o" in the exclude filters the user expects object
files (ending with .o) are excluded. Without escaping this would match
every file and folder ending with o though. This is the case for all
entries of that form in exlude filters ("*.moc", "*.la", etc.)
So just escape every dot we find in exclude filters with a backslash
while building the regexp.
BUG: 339908
FIXED-IN: 5.1.1
REVIEW: 120570
M +1 -0 src/file/regexpcache.cpp
http://commits.kde.org/baloo/863ccc6f7901528338efabfef78098fc72cbd94f
diff --git a/src/file/regexpcache.cpp b/src/file/regexpcache.cpp
index 5963751..61f07d6 100644
--- a/src/file/regexpcache.cpp
+++ b/src/file/regexpcache.cpp
@@ -49,6 +49,7 @@ void RegExpCache::rebuildCacheFromFilterList(const QStringList& filters)
m_regexpCache.clear();
Q_FOREACH (const QString& filter, filters) {
QString f = filter;
+ f.replace(QLatin1Char('.'), QStringLiteral("\\."));
f.replace(QLatin1Char('?'), QLatin1Char('.'));
f.replace(QStringLiteral("*"), QStringLiteral(".*"));
f = QLatin1String("^") + f + QLatin1String("$");
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic