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
parent
b3871dc804
commit
2350c7e35c
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue