From: Pekka Riikonen Date: Mon, 4 Nov 2002 14:28:34 +0000 (+0000) Subject: UTF-8 decode topics in TOPIC and LIST command replys. X-Git-Tag: 1.2.beta1~943 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=9dfe66a535652982ea7bc7df50e31096437c8528;p=crypto.git UTF-8 decode topics in TOPIC and LIST command replys. --- diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index d2ccc9d5..d8db45c8 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -1365,6 +1365,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn, char *topic, *name; int usercount; char users[20]; + char tmp[256], *cp, *dm = NULL; if (!success) return; @@ -1373,6 +1374,19 @@ silc_command_reply(SilcClient client, SilcClientConnection conn, name = va_arg(vp, char *); topic = va_arg(vp, char *); usercount = va_arg(vp, int); + + if (!silc_term_utf8() && silc_utf8_valid(topic, strlen(topic))) { + memset(tmp, 0, sizeof(tmp)); + cp = tmp; + if (strlen(topic) > sizeof(tmp) - 1) { + dm = silc_calloc(strlen(topic) + 1, sizeof(*dm)); + cp = dm; + } + + silc_utf8_decode(topic, strlen(topic), SILC_STRING_LANGUAGE, + cp, strlen(topic)); + topic = cp; + } if (status == SILC_STATUS_LIST_START || status == SILC_STATUS_OK) @@ -1386,6 +1400,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn, printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP, SILCTXT_LIST, name, users, topic ? topic : ""); + silc_free(dm); } break; @@ -1584,13 +1599,27 @@ silc_command_reply(SilcClient client, SilcClientConnection conn, { SilcChannelEntry channel; char *topic; + char tmp[256], *cp, *dm = NULL; if (!success) return; channel = va_arg(vp, SilcChannelEntry); topic = va_arg(vp, char *); - + + if (!silc_term_utf8() && silc_utf8_valid(topic, strlen(topic))) { + memset(tmp, 0, sizeof(tmp)); + cp = tmp; + if (strlen(topic) > sizeof(tmp) - 1) { + dm = silc_calloc(strlen(topic) + 1, sizeof(*dm)); + cp = dm; + } + + silc_utf8_decode(topic, strlen(topic), SILC_STRING_LANGUAGE, + cp, strlen(topic)); + topic = cp; + } + if (topic) { chanrec = silc_channel_find_entry(server, channel); if (chanrec) { @@ -1606,6 +1635,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn, MSGLEVEL_CRAP, SILCTXT_CHANNEL_TOPIC_NOT_SET, channel->channel_name); } + silc_free(dm); } break;