Changeset fed4f76
- Timestamp:
- 2015-01-16T19:50:25Z (10 years ago)
- Branches:
- master
- Children:
- ecbd22a
- Parents:
- 4cff28f
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
r4cff28f rfed4f76 780 780 return NULL; 781 781 } 782 783 /* Takes a string, truncates it where it's safe, returns the new length */ 784 int truncate_utf8( char *string, int maxlen ) 785 { 786 char *end; 787 g_utf8_validate( (const gchar *) string, maxlen, (const gchar **) &end ); 788 *end = '\0'; 789 return end - string; 790 } -
lib/misc.h
r4cff28f rfed4f76 150 150 G_MODULE_EXPORT char **split_command_parts( char *command, int limit ); 151 151 G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len ); 152 G_MODULE_EXPORT int truncate_utf8( char *string, int maxlen ); 152 153 153 154 #endif -
nick.c
r4cff28f rfed4f76 227 227 { 228 228 nick_strip( irc, rets ); 229 rets[MAX_NICK_LENGTH] = '\0';229 truncate_utf8( rets, MAX_NICK_LENGTH ); 230 230 return rets; 231 231 } … … 252 252 else 253 253 { 254 nick[0] ++; 254 /* We've got no more space for underscores, 255 so truncate it and replace the last three 256 chars with a random "_XX" suffix */ 257 int len = truncate_utf8( nick, MAX_NICK_LENGTH - 3 ); 258 nick[len] = '_'; 259 g_snprintf(nick + len + 1, 3, "%2x", rand() ); 255 260 } 256 261 … … 400 405 if( strlen( down ) > strlen( nick ) ) 401 406 { 402 /* Well crap. Corrupt it if we have to. */ 403 down[strlen(nick)] = '\0'; 407 truncate_utf8( down, strlen(nick) ); 404 408 } 405 409 strcpy( nick, down );
Note: See TracChangeset
for help on using the changeset viewer.