From 94d52d64c1ad3d55f210e1fc8e6345d54c4e46d5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 2 Dec 2007 11:00:15 +0000 Subject: Added charset checks on incoming msgs (from the IRC side) to prevent possible crashes/other odd behaviour in IM modules (or a GLib function that crashes on non-UTF-8 strings). --- irc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'irc.c') diff --git a/irc.c b/irc.c index 5531addb..01d4c47e 100644 --- a/irc.c +++ b/irc.c @@ -319,11 +319,22 @@ void irc_process( irc_t *irc ) break; } - if( ( cs = set_getstr( &irc->set, "charset" ) ) && ( g_strcasecmp( cs, "utf-8" ) != 0 ) ) + if( ( cs = set_getstr( &irc->set, "charset" ) ) ) { conv[IRC_MAX_LINE] = 0; - if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) != -1 ) - lines[i] = conv; + if( do_iconv( cs, "UTF-8", lines[i], conv, 0, IRC_MAX_LINE - 2 ) == -1 ) + { + if( irc->status & USTATUS_LOGGED_IN ) + irc_usermsg( irc, "ERROR: Charset mismatch detected. The charset " + "setting is currently set to %s, so please make " + "sure your IRC client will send and accept text in " + "that charset, or tell BitlBee which charset to " + "expect by changing the charset setting. See " + "`help set charset' for more information. Your " + "message was ignored.", cs ); + *conv = 0; + } + lines[i] = conv; } if( ( cmd = irc_parse_line( lines[i] ) ) == NULL ) -- cgit v1.2.3