Topic UTF-8 decoding. Bug #82.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 24 Nov 2002 19:32:05 +0000 (19:32 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 24 Nov 2002 19:32:05 +0000 (19:32 +0000)
CHANGES
apps/irssi/src/silc/core/client_ops.c

diff --git a/CHANGES b/CHANGES
index c3b3d074ab4263a8d4e21da7c07c477a4a33ca94..d0f0c0295e1f880b8d3a214f8153dd061f3f6ed2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,10 @@ Sun Nov 24 18:26:42 EET 2002  Pekka Riikonen <priikone@silcnet.org>
        * 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 <priikone@silcnet.org>
 
        * Added support to backup router protocol for backup to tell
index 9a397ddd508b85afc399775cea5dd9ced2b71bd2..2e54f674610fe2828c071bbd8025ea9b5af8097a 100644 (file)
@@ -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,