From d1d13a4b36f486c1754a8eb9d70df3962dbe9fbd Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 29 Jul 2001 01:35:10 +0000 Subject: [PATCH] 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 --- src/fe-common/core/fe-log.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index 8581c2a8..eb7f9bec 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -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);