aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pietri <antoine.pietri@lrde.epita.fr>2015-03-11 11:49:15 +0100
committerdequis <dx@dxzone.com.ar>2015-03-25 15:50:07 -0300
commitb95d03b74c1186a67f0a5e5ddf909b496505a3b5 (patch)
treeb0d86087f01362809e2f3ab71c7b834caf0979fd
parent098a75b2b2f6a23b5740f6a2032d8a4c8d0d36b2 (diff)
chat_name_hint: normalize utf8 with fallback from the channel name
-rw-r--r--irc_im.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/irc_im.c b/irc_im.c
index d71c9ee9..2a956c44 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -697,7 +697,8 @@ static gboolean bee_irc_chat_name_hint(bee_t *bee, struct groupchat *c, const ch
{
irc_t *irc = bee->ui_data;
irc_channel_t *ic = c->ui_data, *oic;
- char stripped[MAX_NICK_LENGTH + 1], *full_name;
+ char *stripped, *full_name;
+ gsize bytes_written;
if (ic == NULL) {
return FALSE;
@@ -708,18 +709,23 @@ static gboolean bee_irc_chat_name_hint(bee_t *bee, struct groupchat *c, const ch
return FALSE;
}
- strncpy(stripped, name, MAX_NICK_LENGTH);
- stripped[MAX_NICK_LENGTH] = '\0';
+ stripped = g_convert_with_fallback(name, -1, "ASCII//TRANSLIT", "UTF-8", "", NULL, &bytes_written, NULL);
+ if (bytes_written > MAX_NICK_LENGTH) {
+ stripped[MAX_NICK_LENGTH] = '\0';
+ }
+
irc_channel_name_strip(stripped);
if (set_getbool(&bee->set, "lcnicks")) {
nick_lc(irc, stripped);
}
if (stripped[0] == '\0') {
+ g_free(stripped);
return FALSE;
}
full_name = g_strdup_printf("#%s", stripped);
+ g_free(stripped);
if ((oic = irc_channel_by_name(irc, full_name))) {
char *type, *chat_type;