From 2dacc047ece31542ce1654cec428cb2cee358c85 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 13 Nov 2013 15:42:58 +0100 Subject: [PATCH] Remove quotes from perfdata keys. Fixes #5031 --- lib/icinga/pluginutility.cpp | 3 +++ test/icinga-perfdata.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/icinga/pluginutility.cpp b/lib/icinga/pluginutility.cpp index b01a0aa1d..98f6284b9 100644 --- a/lib/icinga/pluginutility.cpp +++ b/lib/icinga/pluginutility.cpp @@ -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) diff --git a/test/icinga-perfdata.cpp b/test/icinga-perfdata.cpp index 04812983c..679480634 100644 --- a/test/icinga-perfdata.cpp +++ b/test/icinga-perfdata.cpp @@ -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"); -- 2.40.0