From fed4f766c05e44e99917909b266c99c052ed9c3e Mon Sep 17 00:00:00 2001 From: dequis Date: Fri, 16 Jan 2015 16:50:25 -0300 Subject: Fix UTF8 nick truncation issues When nicks exceeded the length limit, they were cut at 24 bytes and that sometimes left invalid utf8 at the end, which made the nick_ok() validation fail and often broke those nicks completely. This adds a truncate_utf8 function to cut the string at a safe place Also, the method to deduplicate nicks when there's no more place to add underscores was changed to add "_XX" at the end, where XX are two random hex chars. The previous method in those cases was increasing the value of the first character of the nick... which leads to silly and confusing results (i.e. FacebookUser -> GacebookUser) --- lib/misc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/misc.h') diff --git a/lib/misc.h b/lib/misc.h index d8cce32b..bf587332 100644 --- a/lib/misc.h +++ b/lib/misc.h @@ -149,5 +149,6 @@ G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); G_MODULE_EXPORT int md5_verify_password( char *password, char *hash ); G_MODULE_EXPORT char **split_command_parts( char *command, int limit ); G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len ); +G_MODULE_EXPORT int truncate_utf8( char *string, int maxlen ); #endif -- cgit v1.2.3