~singpolyma/biboumi

af5548897a8395a868f3ff2d716391a0c5ec92fe — Florent Le Coz 10 years ago ccebe90
Cosmetic
1 files changed, 21 insertions(+), 9 deletions(-)

M src/xmpp/xmpp_stanza.cpp
M src/xmpp/xmpp_stanza.cpp => src/xmpp/xmpp_stanza.cpp +21 -9
@@ 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;
}