diff options
author | dequis <dx@dxzone.com.ar> | 2015-08-27 04:25:07 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-08-27 04:25:07 -0300 |
commit | b6a3fbf3b94d1e7e7aee82375661fc0934fec48b (patch) | |
tree | 021a0c9d1eaeb2d8a56b5aa9e60bfbc1d2614bff /irc_channel.c | |
parent | 3c23681f0207e715b38ef2202c62df7cf3fca418 (diff) |
irc_channel_name_gen: handle g_convert_with_fallback failures
First fallback to ASCII without TRANSLIT, and if that fails too, just
give up by returning NULL.
Basically the same thing as 3a27896 (a netbsd specific fix), but for
channel names. This wasn't needed before because the older version of
this code caught the NULL from the ASCII//TRANSLIT attempt and gave up
immediately, while the refactored version lacked null checking.
Diffstat (limited to 'irc_channel.c')
-rw-r--r-- | irc_channel.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/irc_channel.c b/irc_channel.c index 3de68e34..cbd306a3 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -592,6 +592,16 @@ char *irc_channel_name_gen(irc_t *irc, const char *hint) gsize bytes_written; translit_name = g_convert_with_fallback(hint, -1, "ASCII//TRANSLIT", "UTF-8", "", NULL, &bytes_written, NULL); + + if (!translit_name) { + /* Same thing as in nick_gen() in nick.c, try again without //TRANSLIT */ + translit_name = g_convert_with_fallback(hint, -1, "ASCII", "UTF-8", "", NULL, &bytes_written, NULL); + } + + if (!translit_name) { + return NULL; + } + if (bytes_written > MAX_NICK_LENGTH) { translit_name[MAX_NICK_LENGTH] = '\0'; } |