diff options
-rw-r--r-- | src/xmpp/xmpp_stanza.cpp | 30 |
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 += "<"; break; - case '>': buffer += ">"; break; - default: buffer += data[pos]; break; + case '&': + res += "&"; + break; + case '<': + res += "<"; + break; + case '>': + res += ">"; + break; + case '\"': + res += """; + break; + case '\'': + res += "'"; + break; + default: + res += data[pos]; + break; } } - return buffer; + return res; } |