1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-05 20:16:44 +02:00

escape newlines in contact names/status messages

This commit is contained in:
Jfreegman
2014-10-06 16:23:43 -04:00
parent 43552161f9
commit 6492bd12f9
4 changed files with 19 additions and 3 deletions

View File

@ -189,7 +189,7 @@ int qsort_strcasecmp_hlpr(const void *str1, const void *str2)
- cannot start with a space
- must not contain a forward slash (for logfile naming purposes)
- must not contain contiguous spaces */
int valid_nick(char *nick)
int valid_nick(const char *nick)
{
if (!nick[0] || nick[0] == ' ')
return 0;
@ -207,6 +207,17 @@ int valid_nick(char *nick)
return 1;
}
/* Converts all newline 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')
str[i] = ' ';
}
}
/* gets base file name from path or original file name if no path is supplied */
void get_file_name(char *namebuf, int bufsize, const char *pathname)
{