]> granicus.if.org Git - icinga2/commitdiff
Remove quotes from perfdata keys.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 13 Nov 2013 14:42:58 +0000 (15:42 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 13 Nov 2013 14:43:59 +0000 (15:43 +0100)
Fixes #5031

lib/icinga/pluginutility.cpp
test/icinga-perfdata.cpp

index b01a0aa1d08228a93d9668dfddf9d48b60664b8e..98f6284b9f74b20f7509dddac3d96392b8ce5258 100644 (file)
@@ -97,6 +97,9 @@ Value PluginUtility::ParsePerfdata(const String& perfdata)
 
                        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);
 
                        if (spq == String::NPos)
index 04812983c46e4d4642864bbe6cffd1ee85b70e4a..679480634ec4f9d4105b0d3c38695f083ed44b17 100644 (file)
@@ -39,6 +39,12 @@ BOOST_AUTO_TEST_CASE(simple)
        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)
 {
        Dictionary::Ptr pd = PluginUtility::ParsePerfdata("testA=123456 testB=123456");