diff options
author | admin@progandy.co.cc <admin@progandy.co.cc@eced67a3-f377-a0ae-92ae-d6de1850b05a> | 2010-09-15 18:01:16 +0000 |
---|---|---|
committer | admin@progandy.co.cc <admin@progandy.co.cc@eced67a3-f377-a0ae-92ae-d6de1850b05a> | 2010-09-15 18:01:16 +0000 |
commit | 9ff42f0ce72e234de4ab575cb48ca7fa4a9992c7 (patch) | |
tree | 5541aad1b1bb4eca381977f1096ac2706ca1a396 /MirOTR/entities.cpp | |
parent | fa7c6913dd96ba0282af7b5be85213bb1ce32efa (diff) |
- fixed crash in Jabber. maybe other protocls were affected, too.
- added basic html conversion for outgoing data
- fixed html conversion for incoming data
git-svn-id: http://mirotr.googlecode.com/svn/trunk@14 eced67a3-f377-a0ae-92ae-d6de1850b05a
Diffstat (limited to 'MirOTR/entities.cpp')
-rw-r--r-- | MirOTR/entities.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/MirOTR/entities.cpp b/MirOTR/entities.cpp index c757b70..892681b 100644 --- a/MirOTR/entities.cpp +++ b/MirOTR/entities.cpp @@ -393,3 +393,35 @@ size_t decode_html_entities_utf8(char *dest, const char *src, size_t len) *to = 0; return (size_t)(to - dest); } + +char * encode_html_entities_utf8(const char *src) { + const char *pos, *start=src; + std::string buf; + if (! (pos = strpbrk(start, "&<>\"\r")) ) return NULL; + while (pos) { + buf.append(start, pos-start); + start = pos+1; + switch (*pos) { + case '"': + buf.append("""); + break; + case '<': + buf.append("<"); + break; + case '>': + buf.append(">"); + break; + case '&': + buf.append("&"); + break; + case '\r': + buf.append("<br>\r"); + break; + } + pos = strpbrk(start, "&<>\"\r"); + } + if (strlen(start)) buf.append(start); + pos = mir_strdup(buf.c_str()); + buf.clear(); + return (char*)pos; +}
\ No newline at end of file |