aboutsummaryrefslogtreecommitdiff
path: root/src/clientprotocol.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-11-30 03:26:38 +0000
committerGravatar Sadie Powell2022-11-30 03:26:38 +0000
commitbfd4c5d44eda648ae2fb57d8b9db85cf952360ac (patch)
tree9289df1efeec708bfaa5cceb43da6d2fb18a0628 /src/clientprotocol.cpp
parentMake it easier to add tags to a numeric. (diff)
Add a method for quickly escaping a tag value.
Diffstat (limited to 'src/clientprotocol.cpp')
-rw-r--r--src/clientprotocol.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/clientprotocol.cpp b/src/clientprotocol.cpp
index f3838e468..8d245f0ed 100644
--- a/src/clientprotocol.cpp
+++ b/src/clientprotocol.cpp
@@ -68,6 +68,38 @@ const ClientProtocol::SerializedMessage& ClientProtocol::Serializer::SerializeFo
return msg.GetSerialized(Message::SerializedInfo(this, MakeTagWhitelist(user, msg.GetTags())));
}
+std::string CoreExport ClientProtocol::Message::EscapeTag(const std::string& value)
+{
+ std::string ret;
+ ret.reserve(value.size());
+ for (const char& chr : value)
+ {
+ switch (chr)
+ {
+ case ' ':
+ ret.append("\\s");
+ break;
+ case ';':
+ ret.append("\\;");
+ break;
+ case '\\':
+ ret.append("\\\\");
+ break;
+ case '\n':
+ ret.append("\\n");
+ break;
+ case '\r':
+ ret.append("\\r");
+ break;
+ default:
+ ret.push_back(chr);
+ break;
+ }
+ }
+ return ret;
+}
+
+
const ClientProtocol::SerializedMessage& ClientProtocol::Message::GetSerialized(const SerializedInfo& serializeinfo) const
{
// First check if the serialized line they're asking for is in the cache