aboutsummaryrefslogtreecommitdiff
path: root/src/clientprotocol.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-01-02 19:22:40 +0000
committerGravatar Sadie Powell2023-01-02 19:22:40 +0000
commit6d6ccfd24bc247545992279b9c9bb5844ccbc9c9 (patch)
tree5862c3fd16bbd41e339ad2ae987b700975bb6b56 /src/clientprotocol.cpp
parentRelease v4.0.0 alpha 18. (diff)
Add a method for unescaping tags.
Diffstat (limited to 'src/clientprotocol.cpp')
-rw-r--r--src/clientprotocol.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/clientprotocol.cpp b/src/clientprotocol.cpp
index 0ad9b1ee8..6ed2deb0e 100644
--- a/src/clientprotocol.cpp
+++ b/src/clientprotocol.cpp
@@ -99,6 +99,50 @@ std::string ClientProtocol::Message::EscapeTag(const std::string& value)
return ret;
}
+std::string ClientProtocol::Message::UnescapeTag(const std::string& value)
+{
+ std::string ret;
+ ret.reserve(value.size());
+ for (std::string::const_iterator it = value.begin(); it != value.end(); ++it)
+ {
+ char chr = *it;
+ if (chr != '\\')
+ {
+ ret.push_back(chr);
+ continue;
+ }
+
+ it++;
+ if (it != value.end())
+ {
+ chr = *it;
+ switch (chr)
+ {
+ case 's':
+ ret.push_back(' ');
+ break;
+ case ':':
+ ret.push_back(';');
+ break;
+ case '\\':
+ ret.push_back('\\');
+ break;
+ case 'n':
+ ret.push_back('\n');
+ break;
+ case 'r':
+ ret.push_back('\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