From 4c17d19ddb4a039e3ff9e33e87d5f538a0b0c19b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 10 May 2010 10:05:26 +0100 Subject: Fixed irc_channel_name_ok(): One-character channel names are okay, also the first character after the prefix *can* be a number. --- irc_channel.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'irc_channel.c') diff --git a/irc_channel.c b/irc_channel.c index f000a997..28cd7d43 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -201,7 +201,18 @@ void irc_channel_printf( irc_channel_t *ic, char *format, ... ) gboolean irc_channel_name_ok( const char *name ) { - return strchr( CTYPES, name[0] ) != NULL && nick_ok( name + 1 ); + char name_[strlen(name)+1]; + + /* Check if the first character is in CTYPES (#&) */ + if( strchr( CTYPES, name[0] ) == NULL ) + return FALSE; + + /* Check the rest of the name. Just checking name + 1 doesn't work + since it will fail if the first character is a number, or if + it's a one-char channel name - both of which are legal. */ + name_[0] = '_'; + strcpy( name_ + 1, name + 1 ); + return nick_ok( name_ ); } static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ) -- cgit v1.2.3