diff options
-rw-r--r-- | plugins/MirOTR/src/entities.cpp | 18 | ||||
-rw-r--r-- | plugins/MirOTR/src/svcs_proto.cpp | 2 |
2 files changed, 12 insertions, 8 deletions
diff --git a/plugins/MirOTR/src/entities.cpp b/plugins/MirOTR/src/entities.cpp index 87cc198eaa..916bebd608 100644 --- a/plugins/MirOTR/src/entities.cpp +++ b/plugins/MirOTR/src/entities.cpp @@ -391,10 +391,14 @@ size_t decode_html_entities_utf8(char *dest, const char *src, size_t len) return (size_t)(to - dest); } -char * encode_html_entities_utf8(const char *src) { - const char *pos, *start=src; +char* encode_html_entities_utf8(const char *src) +{ + const char *pos = strpbrk(src, "&<>\"\r"); + if (!pos) + return NULL; + + const char *start = src; std::string buf; - if (! (pos = strpbrk(start, "&<>\"\r")) ) return NULL; while (pos) { buf.append(start, pos-start); start = pos+1; @@ -417,8 +421,8 @@ char * encode_html_entities_utf8(const char *src) { } pos = strpbrk(start, "&<>\"\r"); } - if (mir_strlen(start)) buf.append(start); - pos = mir_strdup(buf.c_str()); - buf.clear(); - return (char*)pos; + if (mir_strlen(start)) + buf.append(start); + + return mir_strndup(buf.c_str(), buf.size()); }
\ No newline at end of file diff --git a/plugins/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/src/svcs_proto.cpp index bb88823c04..637497350a 100644 --- a/plugins/MirOTR/src/svcs_proto.cpp +++ b/plugins/MirOTR/src/svcs_proto.cpp @@ -30,7 +30,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ return CallService(MS_PROTO_CHAINSEND, wParam, lParam); } - char *tmpencode = NULL; + ptrA tmpencode; ConnContext *context = otrl_context_find_miranda(otr_user_state, ccs->hContact); if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0) && otr_context_get_trust(context) >= TRUST_UNVERIFIED) { tmpencode = encode_html_entities_utf8(oldmessage); |