Changeset 0f47613
- Timestamp:
- 2007-12-10T22:57:13Z (17 years ago)
- Branches:
- master
- Children:
- d52111a
- Parents:
- 71dc854
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nick.c
r71dc854 r0f47613 154 154 With one difference, we allow dashes. */ 155 155 156 static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^ -_|";157 static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~ -_\\";158 159 void nick_strip( char * 156 static char *nick_lc_chars = "0123456789abcdefghijklmnopqrstuvwxyz{}^`-_|"; 157 static char *nick_uc_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[]~`-_\\"; 158 159 void nick_strip( char *nick ) 160 160 { 161 161 int i, j; … … 170 170 } 171 171 } 172 if( isdigit( nick[0] ) ) 173 { 174 char *orig; 175 176 orig = g_strdup( nick ); 177 g_snprintf( nick, MAX_NICK_LENGTH, "_%s", orig ); 178 g_free( orig ); 179 j ++; 180 } 172 181 while( j <= MAX_NICK_LENGTH ) 173 182 nick[j++] = '\0'; … … 178 187 const char *s; 179 188 180 /* Empty/long nicks are not allowed */181 if( !*nick || strlen( nick ) > MAX_NICK_LENGTH )189 /* Empty/long nicks are not allowed, nor numbers at [0] */ 190 if( !*nick || isdigit( nick[0] ) || strlen( nick ) > MAX_NICK_LENGTH ) 182 191 return( 0 ); 183 192 -
tests/check_nick.c
r71dc854 r0f47613 15 15 "thisisave:ryveryveryverylongnick", 16 16 "t::::est", 17 "test123", 18 "123test", 19 "123", 17 20 NULL }; 18 21 const char *expected[] = { "test", "test", "test", … … 20 23 "thisisaveryveryveryveryl", 21 24 "test", 25 "test123", 26 "_123test", 27 "_123", 22 28 NULL }; 23 29 … … 35 41 START_TEST(test_nick_ok_ok) 36 42 { 37 const char *nicks[] = { "foo", "bar ", "bla[", "blie]",38 "BreEZaH", "\\od^~", NULL };43 const char *nicks[] = { "foo", "bar123", "bla[", "blie]", "BreEZaH", 44 "\\od^~", "_123", "_123test", NULL }; 39 45 int i; 40 46 … … 49 55 { 50 56 const char *nicks[] = { "thisisaveryveryveryveryveryveryverylongnick", 51 "\nillegalchar", "", "nick%", NULL };57 "\nillegalchar", "", "nick%", "123test", NULL }; 52 58 int i; 53 59
Note: See TracChangeset
for help on using the changeset viewer.