From 032f00732af0670e03ce30f5d4d0060a8b5abc82 Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Mon, 11 Apr 2016 21:49:03 +0100 Subject: [PATCH] [CString.StripControls] Srip bg colours when we reset fg --- src/ZNCString.cpp | 2 +- test/StringTest.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ZNCString.cpp b/src/ZNCString.cpp index eaf2cea8..18b60d78 100644 --- a/src/ZNCString.cpp +++ b/src/ZNCString.cpp @@ -1413,7 +1413,7 @@ CString CString::StripControls_n() const { digits++; continue; } - if (ch == ',' && !comma && digits > 0) { + if (ch == ',' && !comma) { comma = true; digits = 0; continue; diff --git a/test/StringTest.cpp b/test/StringTest.cpp index e028778c..b52406cb 100644 --- a/test/StringTest.cpp +++ b/test/StringTest.cpp @@ -263,3 +263,11 @@ TEST(StringTest, Contains) { EXPECT_FALSE( CString("Hello, I'm Bob").Contains("i'm bob", CString::CaseSensitive)); } + +TEST(StringTest, StripControls) { + // Strips reset colours + EXPECT_EQ(CString("\x03test").StripControls(), "test"); + + // Strips reset foreground and set new background colour + EXPECT_EQ(CString("\x03,03test").StripControls(), "test"); +}