diff --git a/src/Utils.cpp b/src/Utils.cpp index 580a725a..3ef8e77c 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -502,7 +502,9 @@ void CUtils::SetMessageTags(CString& sLine, const MCString& mssTags) { if (!sTags.empty()) { sTags += ";"; } - sTags += it->first + "=" + it->second; + sTags += it->first; + if (!it->second.empty()) + sTags += "=" + it->second; } sLine = "@" + sTags + " " + sLine; } diff --git a/test/UtilsTest.cpp b/test/UtilsTest.cpp index 4f4197bb..84a8a878 100644 --- a/test/UtilsTest.cpp +++ b/test/UtilsTest.cpp @@ -37,6 +37,12 @@ TEST(IRC32, GetMessageTags) { exp["a"] = "==b=="; EXPECT_EQ(exp, CUtils::GetMessageTags("@a===b== :rest")); exp.clear(); + + exp["a"] = ""; + exp["b"] = "c"; + exp["d"] = ""; + EXPECT_EQ(exp, CUtils::GetMessageTags("@a;b=c;d :rest")); + exp.clear(); } TEST(IRC32, SetMessageTags) { @@ -54,5 +60,9 @@ TEST(IRC32, SetMessageTags) { tags["c"] = "d"; CUtils::SetMessageTags(sLine, tags); EXPECT_EQ("@a=b;c=d :rest", sLine); + + tags["e"] = ""; + CUtils::SetMessageTags(sLine, tags); + EXPECT_EQ("@a=b;c=d;e :rest", sLine); }