aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nick.c19
-rw-r--r--tests/check_nick.c12
2 files changed, 23 insertions, 8 deletions
diff --git a/nick.c b/nick.c
index 88c3faea..4b05f4a7 100644
--- a/nick.c
+++ b/nick.c
@@ -153,10 +153,10 @@ void nick_del( account_t *acc, const char *handle )
/* Character maps, _lc_[x] == _uc_[x] (but uppercase), according to the RFC's.
With one difference, we allow dashes. */
-static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^-_|";
-static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~-_\\";
+static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^`-_|";
+static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~`-_\\";
-void nick_strip( char * nick )
+void nick_strip( char *nick )
{
int i, j;
@@ -169,6 +169,15 @@ void nick_strip( char * nick )
j++;
}
}
+ if( isdigit( nick[0] ) )
+ {
+ char *orig;
+
+ orig = g_strdup( nick );
+ g_snprintf( nick, MAX_NICK_LENGTH, "_%s", orig );
+ g_free( orig );
+ j ++;
+ }
while( j <= MAX_NICK_LENGTH )
nick[j++] = '\0';
}
@@ -177,8 +186,8 @@ int nick_ok( const char *nick )
{
const char *s;
- /* Empty/long nicks are not allowed */
- if( !*nick || strlen( nick ) > MAX_NICK_LENGTH )
+ /* Empty/long nicks are not allowed, nor numbers at [0] */
+ if( !*nick || isdigit( nick[0] ) || strlen( nick ) > MAX_NICK_LENGTH )
return( 0 );
for( s = nick; *s; s ++ )
diff --git a/tests/check_nick.c b/tests/check_nick.c
index 714c4fdc..6c4267cd 100644
--- a/tests/check_nick.c
+++ b/tests/check_nick.c
@@ -14,11 +14,17 @@ START_TEST(test_nick_strip)
"thisisaveryveryveryverylongnick",
"thisisave:ryveryveryverylongnick",
"t::::est",
+ "test123",
+ "123test",
+ "123",
NULL };
const char *expected[] = { "test", "test", "test",
"thisisaveryveryveryveryl",
"thisisaveryveryveryveryl",
"test",
+ "test123",
+ "_123test",
+ "_123",
NULL };
for (i = 0; get[i]; i++) {
@@ -34,8 +40,8 @@ END_TEST
START_TEST(test_nick_ok_ok)
{
- const char *nicks[] = { "foo", "bar", "bla[", "blie]",
- "BreEZaH", "\\od^~", NULL };
+ const char *nicks[] = { "foo", "bar123", "bla[", "blie]", "BreEZaH",
+ "\\od^~", "_123", "_123test", NULL };
int i;
for (i = 0; nicks[i]; i++) {
@@ -48,7 +54,7 @@ END_TEST
START_TEST(test_nick_ok_notok)
{
const char *nicks[] = { "thisisaveryveryveryveryveryveryverylongnick",
- "\nillegalchar", "", "nick%", NULL };
+ "\nillegalchar", "", "nick%", "123test", NULL };
int i;
for (i = 0; nicks[i]; i++) {