Commit e28147bf authored by Arjun AK's avatar Arjun AK
Browse files

Ensure input is a valid regexp before enabling regexp filter mode

Checking whether the input contains '*', '?' or '[' alone will
not do since there can be files with '[' in their name.

REVIEW: 120986
BUG: 340470
FIXED-IN: 14.12
parent a994524d
......@@ -43,10 +43,7 @@ void KFileItemModelFilter::setPattern(const QString& filter)
m_pattern = filter;
m_lowerCasePattern = filter.toLower();
m_useRegExp = filter.contains('*') ||
filter.contains('?') ||
filter.contains('[');
if (m_useRegExp) {
if (filter.contains('*') || filter.contains('?') || filter.contains('[')) {
if (!m_regExp) {
m_regExp = new QRegExp();
m_regExp->setCaseSensitivity(Qt::CaseInsensitive);
......@@ -54,6 +51,9 @@ void KFileItemModelFilter::setPattern(const QString& filter)
m_regExp->setPatternSyntax(QRegExp::WildcardUnix);
}
m_regExp->setPattern(filter);
m_useRegExp = m_regExp->isValid();
} else {
m_useRegExp = false;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment