From 936d5f139f0450ab1d6af96b5d91a776483e0455 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Tue, 8 Jul 2014 13:12:43 +0200 Subject: ical.c: Remove newlines from item summaries Newline characters are not allowed in calcurse item descriptions. Replace any newlines in iCal summary lines with spaces. Fixes GitHub issue #6. Reported-by: Jonathan McCrohan Signed-off-by: Lukas Fleischer --- src/ical.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ical.c b/src/ical.c index 0aa5da7..d953b0e 100644 --- a/src/ical.c +++ b/src/ical.c @@ -843,13 +843,19 @@ static char *ical_read_summary(char *line) { char *p, *summary; - if ((p = strchr(line, ':')) != NULL) { - p++; - summary = ical_unformat_line(p); - return summary; - } else { + p = strchr(line, ':'); + if (!p) return NULL; - } + + summary = ical_unformat_line(p + 1); + if (!summary) + return NULL; + + /* Event summaries must not contain newlines. */ + for (p = strchr(summary, '\n'); p; p = strchr(p, '\n')) + *p = ' '; + + return summary; } static void -- cgit v1.2.3-70-g09d2