# HG changeset patch # User franky # Date 1455916455 -3600 # Node ID f3bd1564fa70094b454b28287d55820c3ee2f291 # Parent df5837a72b35068231499da0915579c44409b0e9 Stop html-escaping otr messages and do only strip known tags. We'd like to remove that for good, but pidgin-otr and Adium are still sending html tags. diff -r df5837a72b35 -r f3bd1564fa70 mcabber/mcabber/nohtml.c --- a/mcabber/mcabber/nohtml.c Sat Feb 13 13:48:43 2016 +0100 +++ b/mcabber/mcabber/nohtml.c Fri Feb 19 22:14:15 2016 +0100 @@ -38,17 +38,15 @@ */ char *html_strip(const char *htmlbuf) { - int i, j=0; + int i, j=0, html_len; char *nohtml; if (!htmlbuf) return(NULL); nohtml = g_strdup(htmlbuf); - if (!strchr(htmlbuf, '&') && !strchr(htmlbuf, '<')) - return(nohtml); - - for (i = 0; i < (int)strlen(htmlbuf); i++) { + html_len = (int)strlen(htmlbuf); + for (i = 0; i < html_len; i++) { if (htmlbuf[i] == '&') { if (!strncmp(&htmlbuf[i],"&",5)) { nohtml[j] = '&'; @@ -65,15 +63,26 @@ } else if (!strncmp(&htmlbuf[i],">", 4)) { nohtml[j] = '>'; i += 3; + } else { + nohtml[j] = htmlbuf[i]; } - } else if (!strncmp(&htmlbuf[i],"
", 4) || - !strncmp(&htmlbuf[i],"
", 5)) { - nohtml[j] = '\n'; - i += (htmlbuf[i+3] == '/' ? 4 : 3); } else if (htmlbuf[i] == '<') { - /* Let's strip all unknown tags */ - j--; - while (htmlbuf[++i] != '>'); + if (!strncmp(&htmlbuf[i],"
", 4)) { + nohtml[j] = '\n'; + i += 3; + } else if (!strncmp(&htmlbuf[i],"
", 5)) { + nohtml[j] = '\n'; + i += 4; + } else if (!strncmp(&htmlbuf[i],"", 6)) { + /* Let's strip from Adium */ + i += 5; + j--; + } else if (!strncmp(&htmlbuf[i],"", 7)) { + i += 6; + j--; + } else { + nohtml[j] = htmlbuf[i]; + } } else nohtml[j] = htmlbuf[i]; j++; diff -r df5837a72b35 -r f3bd1564fa70 mcabber/mcabber/otr.c --- a/mcabber/mcabber/otr.c Sat Feb 13 13:48:43 2016 +0100 +++ b/mcabber/mcabber/otr.c Fri Feb 19 22:14:15 2016 +0100 @@ -610,7 +610,7 @@ { gcry_error_t err; char *newmessage = NULL; - char *htmlmsg, *rmsg; + char *rmsg; ConnContext *ctx = otr_get_context(buddy); if (!encryption_status) @@ -633,18 +633,16 @@ NULL, NULL, NULL); #endif else { - htmlmsg = html_escape(msg); err = otrl_message_sending(userstate, &ops, NULL, ctx->accountname, #ifdef HAVE_LIBOTR3 - ctx->protocol, ctx->username, htmlmsg, NULL, + ctx->protocol, ctx->username, msg, NULL, &newmessage, NULL, NULL); #else // INSTAG XXX ctx->protocol, ctx->username, OTRL_INSTAG_BEST, - htmlmsg, NULL, &newmessage, OTRL_FRAGMENT_SEND_SKIP, + msg, NULL, &newmessage, OTRL_FRAGMENT_SEND_SKIP, NULL, NULL, NULL); #endif - g_free(htmlmsg); } if (err)