Module: check_mk
Branch: master
Commit: 93f08352f54306634fff74b60912a44a7d108b9a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=93f08352f54306…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Apr 4 10:12:30 2019 +0200
Fixed macro expansion in in Livestatus.
Unterminated dollar signs were handled incorrectly: The part of the text
before such a dollar sign was repeated, e.g. "foo$bar" was incorreclty
expanded to "foofoo$bar", although it should remain unchanged.
CMK-1925
Change-Id: If18c9083ffeeff42c8f4e52a748e43f32a959347
---
livestatus/src/OffsetStringMacroColumn.cc | 2 +-
livestatus/src/test/test_OffsetStringMacroColumn.cc | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/livestatus/src/OffsetStringMacroColumn.cc
b/livestatus/src/OffsetStringMacroColumn.cc
index e255474..e902b76 100644
--- a/livestatus/src/OffsetStringMacroColumn.cc
+++ b/livestatus/src/OffsetStringMacroColumn.cc
@@ -56,7 +56,7 @@ std::string OffsetStringMacroColumn::expandMacros(const std::string
&raw,
result += std::string(scan, dollar - scan);
const char *otherdollar = strchr(dollar + 1, '$');
if (otherdollar == nullptr) { // unterminated macro, do not expand
- result += scan;
+ result += dollar;
break;
}
std::string macroname =
diff --git a/livestatus/src/test/test_OffsetStringMacroColumn.cc
b/livestatus/src/test/test_OffsetStringMacroColumn.cc
index ea5e8c6..b98766c 100644
--- a/livestatus/src/test/test_OffsetStringMacroColumn.cc
+++ b/livestatus/src/test/test_OffsetStringMacroColumn.cc
@@ -202,7 +202,7 @@ TEST_F(OffsetStringHostMacroColumnTest, border_cases) {
EXPECT_EQ("$", expanded_host_notes());
set_host_notes("foo$bar");
- EXPECT_EQ("foofoo$bar", expanded_host_notes()); // TODO(sp) WRONG!!!
+ EXPECT_EQ("foo$bar", expanded_host_notes());
set_host_notes("checking $USER0$...");
EXPECT_EQ("checking $USER0$...", expanded_host_notes());
@@ -319,7 +319,7 @@ TEST_F(OffsetStringServiceMacroColumnTest, border_cases) {
EXPECT_EQ("$", expanded_service_notes());
set_service_notes("foo$bar");
- EXPECT_EQ("foofoo$bar", expanded_service_notes()); // TODO(sp) WRONG!!!
+ EXPECT_EQ("foo$bar", expanded_service_notes());
set_service_notes("checking $USER0$...");
EXPECT_EQ("checking $USER0$...", expanded_service_notes());