From 980a8a486ee0c57101b5be931c9c2a253e70fb9e Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 24 Nov 2002 19:32:05 +0000 Subject: [PATCH] Topic UTF-8 decoding. Bug #82. --- CHANGES | 4 ++++ apps/irssi/src/silc/core/client_ops.c | 34 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/CHANGES b/CHANGES index c3b3d074..d0f0c029 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,10 @@ Sun Nov 24 18:26:42 EET 2002 Pekka Riikonen * Fixed few double frees from client library. Fixes at least Bug #81, possibly others too. + * UTF-8 decode topics also in JOIN command reply and TOPIC_SET + notifys in Irssi SILC Client. Affected file is + irssi/src/silc/core/client_ops.c. Bug #82. + Fri Nov 22 18:34:20 EET 2002 Pekka Riikonen * Added support to backup router protocol for backup to tell diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index 9a397ddd..2e54f674 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -477,9 +477,26 @@ void silc_notify(SilcClient client, SilcClientConnection conn, chanrec = silc_channel_find_entry(server, channel); if (chanrec != NULL) { + char tmp2[256], *cp, *dm = NULL; + g_free_not_null(chanrec->topic); + if (tmp && !silc_term_utf8() && silc_utf8_valid(tmp, strlen(tmp))) { + memset(tmp2, 0, sizeof(tmp2)); + cp = tmp2; + if (strlen(tmp) > sizeof(tmp2) - 1) { + dm = silc_calloc(strlen(tmp) + 1, sizeof(*dm)); + cp = dm; + } + + silc_utf8_decode(tmp, strlen(tmp), SILC_STRING_LANGUAGE, + cp, strlen(tmp)); + tmp = cp; + } + chanrec->topic = *tmp == '\0' ? NULL : g_strdup(tmp); signal_emit("channel topic changed", 1, chanrec); + + silc_free(dm); } if (idtype == SILC_ID_CLIENT) { @@ -1362,9 +1379,26 @@ silc_command_reply(SilcClient client, SilcClientConnection conn, chanrec = silc_channel_create(server, channel, channel, TRUE); if (topic) { + char tmp[256], *cp, *dm = NULL; g_free_not_null(chanrec->topic); + + 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; + } + chanrec->topic = *topic == '\0' ? NULL : g_strdup(topic); signal_emit("channel topic changed", 1, chanrec); + + silc_free(dm); } mode = silc_client_chmode(modei, -- 2.43.0