aboutsummaryrefslogtreecommitdiffstats
path: root/otr.c
diff options
context:
space:
mode:
authorSven Moritz Hallberg <pesco@khjk.org>2011-06-29 03:35:18 +0200
committerSven Moritz Hallberg <pesco@khjk.org>2011-06-29 03:35:18 +0200
commit1082395cb29e7d0bde7ee55fe1e5d73b41e0e984 (patch)
tree60a4a8017f41461c33056313e0db17a7ed725c49 /otr.c
parent9a57b1f353e733bbb5d3c8dd91e551dd307458dd (diff)
treat OTR plaintext as HTML (setting otr_does_html)
Diffstat (limited to 'otr.c')
-rw-r--r--otr.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/otr.c b/otr.c
index e16fbf2a..843aa3fa 100644
--- a/otr.c
+++ b/otr.c
@@ -239,6 +239,8 @@ gboolean otr_irc_new(irc_t *irc)
l = g_slist_prepend( l, "manual" );
l = g_slist_prepend( l, "always" );
s->eval_data = l;
+
+ s = set_add( &irc->b->set, "otr_does_html", "true", set_eval_bool, irc );
return TRUE;
}
@@ -387,26 +389,38 @@ char *otr_filter_msg_in(irc_user_t *iu, char *msg, int flags)
/* OTR has processed this message */
ConnContext *context = otrl_context_find(irc->otr->us, iu->bu->handle,
ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, NULL);
- if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
- set_getbool(&ic->bee->set, "otr_color_encrypted")) {
- /* color according to f'print trust */
- int color;
- const char *trust = context->active_fingerprint->trust;
- if(trust && trust[0] != '\0')
- color=3; /* green */
- else
- color=5; /* red */
-
- if(newmsg[0] == ',') {
- /* could be a problem with the color code */
- /* insert a space between color spec and message */
- colormsg = g_strdup_printf("\x03%.2d %s\x0F", color, newmsg);
- } else {
- colormsg = g_strdup_printf("\x03%.2d%s\x0F", color, newmsg);
+
+ if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
+ /* HTML decoding */
+ /* perform any necessary stripping that the top level would miss */
+ if(set_getbool(&ic->bee->set, "otr_does_html") &&
+ !(ic->flags & OPT_DOES_HTML) &&
+ set_getbool(&ic->bee->set, "strip_html")) {
+ strip_html(newmsg);
+ }
+
+ /* coloring */
+ if(set_getbool(&ic->bee->set, "otr_color_encrypted")) {
+ /* color according to f'print trust */
+ int color;
+ const char *trust = context->active_fingerprint->trust;
+ if(trust && trust[0] != '\0')
+ color=3; /* green */
+ else
+ color=5; /* red */
+
+ if(newmsg[0] == ',') {
+ /* could be a problem with the color code */
+ /* insert a space between color spec and message */
+ colormsg = g_strdup_printf("\x03%.2d %s\x0F", color, newmsg);
+ } else {
+ colormsg = g_strdup_printf("\x03%.2d%s\x0F", color, newmsg);
+ }
}
} else {
colormsg = g_strdup(newmsg);
}
+
otrl_message_free(newmsg);
return colormsg;
}
@@ -424,6 +438,13 @@ char *otr_filter_msg_out(irc_user_t *iu, char *msg, int flags)
if(ic->acc->prpl->options & OPT_NOOTR) {
return msg;
}
+
+ /* HTML encoding */
+ /* consider OTR plaintext to be HTML if otr_does_html is set */
+ if(set_getbool(&ic->bee->set, "otr_does_html") &&
+ (g_strncasecmp(msg, "<html>", 6) != 0)) {
+ msg = escape_html(msg);
+ }
st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
ic->acc->user, ic->acc->prpl->name, iu->bu->handle,