Fix decoding of escaped characters in imported text
Stick strictly to RFC 5545, 3.3.11, Text, for SUMMARY and DESCRIPTION. Adresses Github issue #271. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
1cb2691342
commit
ffbf714c9e
31
src/ical.c
31
src/ical.c
@ -440,8 +440,9 @@ ical_store_apoint(char *mesg, char *note, long start, long dur,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns an allocated string representing the string given in argument once
|
* Returns an allocated string representing the argument string with escaped
|
||||||
* unformatted.
|
* characters decoded, or NULL on error.
|
||||||
|
* The string is assumed to be the value part of a SUMMARY or DESCRIPTION line.
|
||||||
*/
|
*/
|
||||||
static char *ical_unformat_line(char *line)
|
static char *ical_unformat_line(char *line)
|
||||||
{
|
{
|
||||||
@ -453,25 +454,29 @@ static char *ical_unformat_line(char *line)
|
|||||||
switch (*p) {
|
switch (*p) {
|
||||||
case '\\':
|
case '\\':
|
||||||
switch (*(p + 1)) {
|
switch (*(p + 1)) {
|
||||||
|
case 'N':
|
||||||
case 'n':
|
case 'n':
|
||||||
string_catf(&s, "%c", '\n');
|
string_catf(&s, "%c", '\n');
|
||||||
p++;
|
p++;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case '\\':
|
||||||
string_catf(&s, "%c", '\t');
|
|
||||||
p++;
|
|
||||||
break;
|
|
||||||
case ';':
|
case ';':
|
||||||
case ':':
|
|
||||||
case ',':
|
case ',':
|
||||||
string_catf(&s, "%c", *(p + 1));
|
string_catf(&s, "%c", *(p + 1));
|
||||||
p++;
|
p++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
string_catf(&s, "%c", *p);
|
mem_free(s.buf);
|
||||||
break;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ',':
|
||||||
|
case ';':
|
||||||
|
/*
|
||||||
|
* No list or field separator allowed.
|
||||||
|
*/
|
||||||
|
mem_free(s.buf);
|
||||||
|
return NULL;
|
||||||
default:
|
default:
|
||||||
string_catf(&s, "%c", *p);
|
string_catf(&s, "%c", *p);
|
||||||
break;
|
break;
|
||||||
@ -928,8 +933,12 @@ static char *ical_read_summary(char *line, unsigned *noskipped,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Event summaries must not contain newlines. */
|
/* Event summaries must not contain newlines. */
|
||||||
for (p = strchr(summary, '\n'); p; p = strchr(p, '\n'))
|
if (strchr(summary, '\n')) {
|
||||||
*p = ' ';
|
ical_log(log, item_type, itemline, _("line break in summary."));
|
||||||
|
(*noskipped)++;
|
||||||
|
mem_free(summary);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ END:VEVENT
|
|||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTART:20000101T000000
|
DTSTART:20000101T000000
|
||||||
DURATION:P1DT1H1M1S
|
DURATION:P1DT1H1M1S
|
||||||
SUMMARY:One day, one hour, one minute and one second
|
SUMMARY:One day\, one hour\, one minute and one second
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTART:20000101T000000
|
DTSTART:20000101T000000
|
||||||
DURATION:PT1H1M1S
|
DURATION:PT1H1M1S
|
||||||
SUMMARY:One hour, one minute and one second
|
SUMMARY:One hour\, one minute and one second
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTART:20000101T000000
|
DTSTART:20000101T000000
|
||||||
|
@ -56,7 +56,7 @@ DTSTART:20120601T150000
|
|||||||
DURATION:PT5H10S
|
DURATION:PT5H10S
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
SUMMARY:5 hours, 30 minutes and 10 seconds
|
SUMMARY:5 hours\, 30 minutes and 10 seconds
|
||||||
DTSTART:20120601T150000
|
DTSTART:20120601T150000
|
||||||
DURATION:PT5H30M10S
|
DURATION:PT5H30M10S
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user