Escape message tag values (ref #684)

This commit is contained in:
J-P Nurmi
2014-09-29 14:23:06 +02:00
parent 615801c40e
commit 92c9a2e6ae
5 changed files with 81 additions and 9 deletions
+28
View File
@@ -43,6 +43,19 @@ TEST(IRC32, GetMessageTags) {
exp["d"] = "";
EXPECT_EQ(exp, CUtils::GetMessageTags("@a;b=c;d :rest"));
exp.clear();
exp["semi-colon"] += ';';
exp["space"] += ' ';
exp["NUL"] += '\0';
exp["backslash"] += '\\';
exp["CR"] += '\r';
exp["LF"] += '\n';
EXPECT_EQ(exp, CUtils::GetMessageTags(R"(@semi-colon=\:;space=\s;NUL=\0;backslash=\\;CR=\r;LF=\n :rest)"));
exp.clear();
exp["a"] = "; \\\r\n";
EXPECT_EQ(exp, CUtils::GetMessageTags(R"(@a=\:\s\\\r\n :rest)"));
exp.clear();
}
TEST(IRC32, SetMessageTags) {
@@ -64,5 +77,20 @@ TEST(IRC32, SetMessageTags) {
tags["e"] = "";
CUtils::SetMessageTags(sLine, tags);
EXPECT_EQ("@a=b;c=d;e :rest", sLine);
tags.clear();
tags["semi-colon"] += ';';
tags["space"] += ' ';
tags["NUL"] += '\0';
tags["backslash"] += '\\';
tags["CR"] += '\r';
tags["LF"] += '\n';
CUtils::SetMessageTags(sLine, tags);
EXPECT_EQ(R"(@CR=\r;LF=\n;NUL=\0;backslash=\\;semi-colon=\:;space=\s :rest)", sLine);
tags.clear();
tags["a"] = "; \\\r\n";
CUtils::SetMessageTags(sLine, tags);
EXPECT_EQ(R"(@a=\:\s\\\r\n :rest)", sLine);
}