summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/xmpp_stanza.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/xmpp/xmpp_stanza.cpp b/src/xmpp/xmpp_stanza.cpp
index 4c0088e..d856836 100644
--- a/src/xmpp/xmpp_stanza.cpp
+++ b/src/xmpp/xmpp_stanza.cpp
@@ -5,20 +5,32 @@
std::string xml_escape(const std::string& data)
{
std::string res;
- buffer.reserve(data.size());
- for(size_t pos = 0; pos != data.size(); ++pos)
+ res.reserve(data.size());
+ for (size_t pos = 0; pos != data.size(); ++pos)
{
switch(data[pos])
{
- case '&': buffer += "&"; break;
- case '\"': buffer += """; break;
- case '\'': buffer += "'"; break;
- case '<': buffer += "&lt;"; break;
- case '>': buffer += "&gt;"; break;
- default: buffer += data[pos]; break;
+ case '&':
+ res += "&amp;";
+ break;
+ case '<':
+ res += "&lt;";
+ break;
+ case '>':
+ res += "&gt;";
+ break;
+ case '\"':
+ res += "&quot;";
+ break;
+ case '\'':
+ res += "&apos;";
+ break;
+ default:
+ res += data[pos];
+ break;
}
}
- return buffer;
+ return res;
}