1
0
mirror of https://github.com/irssi/irssi.git synced 2024-06-30 06:45:25 +00:00

Escape % chars in logs so strftime() won't mess with them.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1667 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-07-29 01:35:10 +00:00 committed by cras
parent 11072cc4d7
commit d1d13a4b36

View File

@ -365,6 +365,26 @@ static void autologs_close_all(void)
}
}
/* '%' -> '%%', '/' -> '_' */
static char *escape_target(const char *target)
{
char *str, *p;
p = str = g_malloc(strlen(target)*2+1);
while (*target != '\0') {
if (*target == '/')
*p++ = '_';
else {
if (*target == '%')
*p++ = '%';
*p++ = *target++;
}
}
*p = '\0';
return str;
}
static void autolog_open(SERVER_REC *server, const char *target)
{
LOG_REC *log;
@ -378,9 +398,10 @@ static void autolog_open(SERVER_REC *server, const char *target)
}
/* '/' -> '_' - don't even accidentally try to log to
#../../../file if you happen to join to such channel.. */
fixed_target = g_strdup(target);
replace_chars(fixed_target, '/', '_');
#../../../file if you happen to join to such channel..
'%' -> '%%' - so strftime() won't mess with them */
fixed_target = escape_target(target);
fname = parse_special_string(autolog_path, server, NULL,
fixed_target, NULL, 0);
g_free(fixed_target);