summaryrefslogtreecommitdiff
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
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!)
-rw-r--r--pith/ical.c21
-rw-r--r--pith/icaltype.h1
-rw-r--r--pith/mailview.c40
-rw-r--r--pith/pine.hlp2
4 files changed, 47 insertions, 17 deletions
diff --git a/pith/ical.c b/pith/ical.c
index b3fe67e2..75212514 100644
--- a/pith/ical.c
+++ b/pith/ical.c
@@ -37,6 +37,7 @@ ICLINE_S *ical_cline_cpy(ICLINE_S *);
ICAL_PARAMETER_S *ical_parameter_cpy(ICAL_PARAMETER_S *param);
char *ical_get_value(char **);
+char *ical_decode(char *, unsigned short);
/* pase component */
void *ical_parse_vcalendar(char **);
@@ -231,6 +232,19 @@ ICAL_PROP_S alarm_prop[] = {
/* Finally, here begins the code. */
+char *
+ical_decode(char *text, unsigned short encoding)
+{
+ char *t;
+ unsigned long callen;
+ if(encoding == ENCQUOTEDPRINTABLE){
+ t = rfc822_qprint ((unsigned char *) text,strlen(text),&callen);
+ strncpy(text, t, strlen(t));
+ }
+ return text;
+}
+
+
/* Return code:
0 - if no errors
-1 - if an error occured
@@ -1965,6 +1979,7 @@ ical_vevent_summary(VCALENDAR_S *vcal)
VEVENT_S *vevent;
GEN_ICLINE_S *gicl;
ICLINE_S *icl;
+ char *k;
if(vcal == NULL) return NULL;
@@ -2170,7 +2185,7 @@ ical_vevent_summary(VCALENDAR_S *vcal)
role && *role ? role : "",
role && *role ? " " : "",
partstat ? partstat : _("[Unknown Reply]"),
- partstat ? " " : "",
+ " ",
cn && *cn ? cn : "",
cn && *cn ? " " : "",
mailto ? mailto : _("Unknown address"));
@@ -2228,13 +2243,13 @@ ical_vevent_summary(VCALENDAR_S *vcal)
}
if(*t == ','){
*u = '\0';
- rv->description[i++] = cpystr(s);
+ rv->description[i++] = cpystr(ical_decode(s, vcal->encoding));
s = u = t+1;
} else
*u++ = *t;
}
*u = '\0';
- rv->description[i++] = cpystr(s);
+ rv->description[i++] = cpystr(ical_decode(s, vcal->encoding));
rv->description[i] = NULL;
fs_give((void **)&v);
} /* end of if(description) */
diff --git a/pith/icaltype.h b/pith/icaltype.h
index 0474464f..8060a412 100644
--- a/pith/icaltype.h
+++ b/pith/icaltype.h
@@ -248,6 +248,7 @@ typedef struct vcalendar_s {
GEN_ICLINE_S *uk_prop;/* in case there is an unknown property */
void **comp; /* an array with the components of a calendar */
ICAL_S *uk_comp; /* in case there is an unknown component */
+ unsigned short encoding; /* save the original encoding. */
} VCALENDAR_S;
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)
diff --git a/pith/pine.hlp b/pith/pine.hlp
index ef58c44d..79cb3c9f 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 243 2017-12-22 22:31:03
+Alpine Commit 244 2017-12-24 19:13:32
============= h_news =================
<HTML>
<HEAD>