Make parsing of categories in logging rules more strict

Do not accept rules with wildcards in the middle.

Change-Id: If6fa71629c46bc4127aa8bd475643bc0e8a9f57c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Kai Koehne 2014-02-25 15:16:17 +01:00 committed by The Qt Project
parent b3871dc804
commit 2350c7e35c
2 changed files with 17 additions and 9 deletions

View File

@ -134,20 +134,20 @@ void QLoggingRule::parse(const QString &pattern)
messageType = QtCriticalMsg;
}
int index = category.indexOf(QLatin1Char('*'));
if (index < 0) {
flags = Invalid;
if (!category.contains(QLatin1Char('*'))) {
flags = FullText;
} else {
flags = Invalid;
if (index == 0) {
flags |= RightFilter;
category.remove(0, 1);
index = category.indexOf(QLatin1Char('*'));
}
if (index == (category.length() - 1)) {
if (category.endsWith(QLatin1Char('*'))) {
flags |= LeftFilter;
category.chop(1);
}
if (category.startsWith(QLatin1Char('*'))) {
flags |= RightFilter;
category.remove(0, 1);
}
if (category.contains(QLatin1Char('*'))) // '*' only supported at start/end
flags = Invalid;
}
}

View File

@ -152,6 +152,14 @@ private slots:
<< QString("*qt.*.debug") << QString("qt.io") << QtDebugMsg << Match;
QTest::newRow("_star_.qt._star_.warning-qt.io")
<< QString("*.qt.*.warning") << QString("qt.io") << QtDebugMsg << NoMatch;
QTest::newRow("**")
<< QString("**") << QString("qt.core.io") << QtDebugMsg << Match;
// * outside of start/end
QTest::newRow("qt.*.io")
<< QString("qt.*.io") << QString("qt.core.io") << QtDebugMsg << Invalid;
QTest::newRow("***")
<< QString("***") << QString("qt.core.io") << QtDebugMsg << Invalid;
}
void QLoggingRule_parse()