summaryrefslogtreecommitdiff
path: root/pith/mailview.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2017-12-24 19:13:39 -0700
committerEduardo Chappa <chappa@washington.edu>2017-12-24 19:13:39 -0700
commit5cb80f3539fd43b785638b676c7ba242bda2f75d (patch)
treeda86ca1533e21f86926db038f9932f191cefa4b4 /pith/mailview.c
parent29798bd68fc0b892fce0fe49ec8859485e3b531b (diff)
downloadalpine-5cb80f3539fd43b785638b676c7ba242bda2f75d.tar.xz
* If the calendar invitation is part of the body of a message instead
of an attachment, Alpine would crash. Reported by Stefan Mueller. * In the previous situation, if a DESCRIPTION is encoded in quoted printable, it needs to be decoded twice (once as part of the calendar onvitation and another as part of the DESCRIPTION text, so when decoding we need to decode quoted-printable, then remove escapes characters, then decode quoted-printable and transform \r\n to \n. Whew!)
Diffstat (limited to 'pith/mailview.c')
-rw-r--r--pith/mailview.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/pith/mailview.c b/pith/mailview.c
index dcdd183d..984b560f 100644
--- a/pith/mailview.c
+++ b/pith/mailview.c
@@ -464,13 +464,13 @@ format_calendar_vevent(VCALENDAR_S *vcal, ATTACH_S *a, HANDLE_S **handlesp, int
snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%*.*s%s", m1, m1, "",
repeat_char(dwid, '-'));
gf_puts(tmp_20k_buf, pc);
- gf_puts(NEWLINE, pc);
+// gf_puts(NEWLINE, pc);
}
int
format_calendar(long int msgno, BODY *body, HANDLE_S **handlesp, int flgs, int width, gf_io_t pc)
{
- char *b64text, *caltext;
+ char *rawtext, *caltext;
unsigned long callen;
VCALENDAR_S *vcal = NULL;
ATTACH_S *a;
@@ -490,20 +490,34 @@ format_calendar(long int msgno, BODY *body, HANDLE_S **handlesp, int flgs, int w
continue;
}
if(b->sparep == NULL){
- b64text = mail_fetch_body(ps_global->mail_stream, msgno, a->number, &callen, 0);
- if(b64text == NULL){
- gf_puts(_("Error fetching calendar text"), pc);
- gf_puts(NEWLINE, pc);
- continue;
+ rawtext = mail_fetch_body(ps_global->mail_stream, msgno, a->number, &callen, 0);
+ if(rawtext == NULL){
+ gf_puts(_("Error fetching calendar text"), pc);
+ gf_puts(NEWLINE, pc);
+ continue;
}
- b64text[callen] = '\0'; /* chop off cookie */
- caltext = rfc822_base64(b64text, strlen(b64text), &callen);
- if(caltext == NULL){
- gf_puts(_("Error in calendar base64 encoding"), pc);
- gf_puts(NEWLINE, pc);
- continue;
+ rawtext[callen] = '\0'; /* chop off cookie */
+ switch(b->encoding){
+ case ENCBASE64:
+ caltext = rfc822_base64(rawtext, strlen(rawtext), &callen);
+ if(caltext == NULL){
+ gf_puts(_("Error in calendar base64 encoding"), pc);
+ gf_puts(NEWLINE, pc);
+ continue;
+ }
+ break;
+
+ case ENCQUOTEDPRINTABLE:
+ caltext = rfc822_qprint ((unsigned char *) rawtext,strlen(rawtext),&callen);
+ if(caltext == NULL){
+ gf_puts(_("Error in calendar quoted printable encoding"), pc);
+ gf_puts(NEWLINE, pc);
+ continue;
+ }
+ break;
}
vcal = ical_parse_text(caltext);
+ if(vcal != NULL) vcal->encoding = b->encoding;
b->sparep = create_body_sparep(iCalType, (void *) vcal);
}
else if(get_body_sparep_type(b->sparep) == iCalType)