summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-02-25 15:16:17 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-13 13:26:26 +0100
commit2350c7e35c7b21ab86e54e43d1e1bfddb1746922 (patch)
tree5a3c9ea48ad5b7e73538af418c3b525fcbc71bed
parentb3871dc8049819ae3e095555f451457567eb4ee3 (diff)
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>
-rw-r--r--src/corelib/io/qloggingregistry.cpp18
-rw-r--r--tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp8
2 files changed, 17 insertions, 9 deletions
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index 20eb2e13f5..ab29c42325 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -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;
}
}
diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
index 56545bb909..5796b2f221 100644
--- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
+++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
@@ -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()