summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-03-17 10:16:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-03 11:07:07 +0200
commitb11adb825c4dfc8429695947cef8f9e3253ad0c2 (patch)
tree6d5ca3c3ffe2d11494b3b51dd67c7ad64274db0d
parent828cfb4019939a39c84e5c5e17dc8cb52e9f63fd (diff)
Logging: Be also more strict with value of logging rule
Only accept lower-case "true" and "false", as documented. The old check didn't match either the documentation, nor the QSettings/ QVariant behavior (where, for a boolean value, any lower-cased content that not empty, "0" or "false" is considered true). Change-Id: I317d29c16a27f862001b9dff02e8298df8acf5a6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/corelib/io/qloggingregistry.cpp13
-rw-r--r--tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp9
2 files changed, 14 insertions, 8 deletions
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index 7e6883fd14..575150f148 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -218,11 +218,14 @@ void QLoggingSettingsParser::setContent(QTextStream &stream)
if ((equalPos != -1)
&& (line.lastIndexOf(QLatin1Char('=')) == equalPos)) {
const QStringRef pattern = line.leftRef(equalPos);
- const QStringRef value = line.midRef(equalPos + 1);
- bool enabled = (value.compare(QLatin1String("true"),
- Qt::CaseInsensitive) == 0);
- QLoggingRule rule(pattern, enabled);
- if (rule.flags != 0)
+ const QStringRef valueStr = line.midRef(equalPos + 1);
+ int value = -1;
+ if (valueStr == QLatin1String("true"))
+ value = 1;
+ else if (valueStr == QLatin1String("false"))
+ value = 0;
+ QLoggingRule rule(pattern, (value == 1));
+ if (rule.flags != 0 && (value != -1))
_rules.append(rule);
else
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
index 3064fd1320..5623990bd1 100644
--- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
+++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
@@ -306,10 +306,13 @@ private slots:
void QLoggingRegistry_checkErrors()
{
QLoggingSettingsParser parser;
- QString warnMsg = QString("Ignoring malformed logging rule: '***=false'");
- QTest::ignoreMessage(QtWarningMsg, warnMsg.toLocal8Bit().constData());
+ QTest::ignoreMessage(QtWarningMsg, "Ignoring malformed logging rule: '***=false'");
+ QTest::ignoreMessage(QtWarningMsg, "Ignoring malformed logging rule: '*=0'");
+ QTest::ignoreMessage(QtWarningMsg, "Ignoring malformed logging rule: '*=TRUE'");
parser.setContent("[Rules]\n"
- "***=false\n");
+ "***=false\n"
+ "*=0\n"
+ "*=TRUE\n");
QVERIFY(parser.rules().isEmpty());
}
};