diff --git a/src/misc_tools.c b/src/misc_tools.c index 1dae6ea..f3552ad 100644 --- a/src/misc_tools.c +++ b/src/misc_tools.c @@ -188,7 +188,8 @@ int qsort_strcasecmp_hlpr(const void *str1, const void *str2) - cannot be empty - cannot start with a space - must not contain a forward slash (for logfile naming purposes) - - must not contain contiguous spaces */ + - must not contain contiguous spaces + - must not contain a newline or tab seqeunce */ int valid_nick(const char *nick) { if (!nick[0] || nick[0] == ' ') @@ -197,23 +198,25 @@ int valid_nick(const char *nick) int i; for (i = 0; nick[i]; ++i) { - if (nick[i] == ' ' && nick[i + 1] == ' ') - return 0; + if ((nick[i] == ' ' && nick[i + 1] == ' ') + || nick[i] == '/' + || nick[i] == '\n' + || nick[i] == '\t' + || nick[i] == '\r') - if (nick[i] == '/') return 0; } return 1; } -/* Converts all newline chars to spaces (use for strings that should be contained to a single line) */ +/* Converts all newline/tab chars to spaces (use for strings that should be contained to a single line) */ void escape_newline_str(char *str, int len) { int i; for (i = 0; i < len; ++i) { - if (str[i] == '\n' || str[i] == '\r') + if (str[i] == '\n' || str[i] == '\r' || str[i] == '\t') str[i] = ' '; } } diff --git a/src/misc_tools.h b/src/misc_tools.h index 77c0353..ff2ce53 100644 --- a/src/misc_tools.h +++ b/src/misc_tools.h @@ -87,10 +87,11 @@ int qsort_strcasecmp_hlpr(const void *str1, const void *str2); - cannot be empty - cannot start with a space - must not contain a forward slash (for logfile naming purposes) - - must not contain contiguous spaces */ + - must not contain contiguous spaces + - must not contain a newline or tab seqeunce */ int valid_nick(const char *nick); -/* Converts all newline chars to spaces (use for strings that should be contained to a single line) */ +/* Converts all newline/tab chars to spaces (use for strings that should be contained to a single line) */ void escape_newline_str(char *str, int len); /* gets base file name from path or original file name if no path is supplied */