Remove quotes from perfdata keys.

Fixes #5031
This commit is contained in:
Gunnar Beutner 2013-11-13 15:42:58 +01:00
parent 4b52528c48
commit 2dacc047ec
2 changed files with 9 additions and 0 deletions

View File

@ -97,6 +97,9 @@ Value PluginUtility::ParsePerfdata(const String& perfdata)
String key = perfdata.SubStr(begin, eqp - begin); String key = perfdata.SubStr(begin, eqp - begin);
if (key.GetLength() > 2 && key[0] == '\'' && key[key.GetLength() - 1] == '\'')
key = key.SubStr(1, key.GetLength() - 2);
size_t spq = perfdata.FindFirstOf(' ', eqp); size_t spq = perfdata.FindFirstOf(' ', eqp);
if (spq == String::NPos) if (spq == String::NPos)

View File

@ -39,6 +39,12 @@ BOOST_AUTO_TEST_CASE(simple)
BOOST_CHECK(str == "test=123456"); BOOST_CHECK(str == "test=123456");
} }
BOOST_AUTO_TEST_CASE(quotes)
{
Dictionary::Ptr pd = PluginUtility::ParsePerfdata("'hello world'=123456");
BOOST_CHECK(pd->Get("hello world") == 123456);
}
BOOST_AUTO_TEST_CASE(multiple) BOOST_AUTO_TEST_CASE(multiple)
{ {
Dictionary::Ptr pd = PluginUtility::ParsePerfdata("testA=123456 testB=123456"); Dictionary::Ptr pd = PluginUtility::ParsePerfdata("testA=123456 testB=123456");