From: Kevin McCarthy Date: Mon, 10 Dec 2018 01:41:58 +0000 (-0800) Subject: Parse and store mime headers in the BODY. X-Git-Tag: mutt-1-12-rel~182 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d8a623bf4c77b9964eebde5cc7df343533ee0451;p=mutt Parse and store mime headers in the BODY. Don't store the field in the header cache though. --- diff --git a/hcache.c b/hcache.c index 4f2bac29..08cfa921 100644 --- a/hcache.c +++ b/hcache.c @@ -468,6 +468,7 @@ dump_body(BODY * c, unsigned char *d, int *off, int convert) nb.parts = NULL; nb.hdr = NULL; nb.aptr = NULL; + nb.mime_headers = NULL; lazy_realloc(&d, *off + sizeof (BODY)); memcpy(d + *off, &nb, sizeof (BODY)); diff --git a/mutt.h b/mutt.h index c6b5db56..90d63f7a 100644 --- a/mutt.h +++ b/mutt.h @@ -734,7 +734,9 @@ typedef struct body time_t stamp; /* time stamp of last * encoding update. */ - + + struct envelope *mime_headers; /* memory hole protected headers */ + unsigned int type : 4; /* content-type primary type */ unsigned int encoding : 3; /* content-transfer-encoding */ unsigned int disposition : 2; /* content-disposition */ diff --git a/muttlib.c b/muttlib.c index 7789479c..2ae92ee7 100644 --- a/muttlib.c +++ b/muttlib.c @@ -226,6 +226,8 @@ void mutt_free_body (BODY **p) mutt_free_header(&b->hdr); } + mutt_free_envelope (&b->mime_headers); + if (b->parts) mutt_free_body (&b->parts); diff --git a/parse.c b/parse.c index af3911d9..44251123 100644 --- a/parse.c +++ b/parse.c @@ -410,6 +410,7 @@ static void parse_content_disposition (const char *s, BODY *ct) BODY *mutt_read_mime_header (FILE *fp, int digest) { BODY *p = mutt_new_body(); + ENVELOPE *e = mutt_new_envelope (); char *c; char *line = safe_malloc (LONG_STRING); size_t linelen = LONG_STRING; @@ -469,6 +470,11 @@ BODY *mutt_read_mime_header (FILE *fp, int digest) } } #endif + else + { + if (mutt_parse_rfc822_line (e, NULL, line, c, 0, 0, 0, NULL)) + p->mime_headers = e; + } } p->offset = ftello (fp); /* Mark the start of the real data */ if (p->type == TYPETEXT && !p->subtype) @@ -478,6 +484,11 @@ BODY *mutt_read_mime_header (FILE *fp, int digest) FREE (&line); + if (p->mime_headers) + rfc2047_decode_envelope (p->mime_headers); + else + mutt_free_envelope (&e); + return (p); }