diff options
-rw-r--r-- | irc.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -51,18 +51,29 @@ static char *set_eval_password( set_t *set, char *value ) static char *set_eval_charset( set_t *set, char *value ) { irc_t *irc = set->data; + char *test; + gsize test_bytes = 0; GIConv ic, oc; if( g_strcasecmp( value, "none" ) == 0 ) value = g_strdup( "utf-8" ); - if( ( ic = g_iconv_open( "utf-8", value ) ) == (GIConv) -1 ) + if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 ) { return NULL; } - if( ( oc = g_iconv_open( value, "utf-8" ) ) == (GIConv) -1 ) + if( ( test = g_convert_with_iconv( " ", 1, oc, NULL, &test_bytes, NULL ) ) == NULL || + test_bytes > 1 ) + { + g_free( test ); + g_iconv_close( oc ); + irc_usermsg( irc, "Unsupported character set: The IRC protocol " + "only supports 8-bit character sets." ); + return NULL; + } + if( ( ic = g_iconv_open( "utf-8", value ) ) == (GIConv) -1 ) { - g_iconv_close( ic ); + g_iconv_close( oc ); return NULL; } |