]> granicus.if.org Git - neomutt/commitdiff
Parse and store mime headers in the BODY
authorKevin McCarthy <kevin@8t8.us>
Mon, 10 Dec 2018 01:41:58 +0000 (17:41 -0800)
committerRichard Russon <rich@flatcap.org>
Mon, 7 Jan 2019 15:09:41 +0000 (15:09 +0000)
Don't store the field in the header cache though.

Co-authored-by: Richard Russon <rich@flatcap.org>
email/body.c
email/body.h
email/parse.c
hcache/serialize.c

index f4e05064d4f0b37cef92e48ebc626991a9be368c..1426809a86ddf5cf119063d21933ecc772b44329 100644 (file)
@@ -32,6 +32,7 @@
 #include "mutt/mutt.h"
 #include "body.h"
 #include "email.h"
+#include "envelope.h"
 #include "mime.h"
 #include "parameter.h"
 
@@ -90,6 +91,7 @@ void mutt_body_free(struct Body **p)
       mutt_email_free(&b->email);
     }
 
+    mutt_env_free(&b->mime_headers);
     mutt_body_free(&b->parts);
     FREE(&b);
   }
index 76dd2082b232e08ee5263621a6104523f8e933df..0ab93e8a9279b2e1b5c6c301e896dfa22b56c247 100644 (file)
@@ -64,6 +64,8 @@ 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 */
index 6acce1cca9c438c9e977a3348a6a9c8e4880d942..1f56f66247394bdb824488b9c01001502d511734 100644 (file)
@@ -1161,6 +1161,7 @@ struct Envelope *mutt_rfc822_read_header(FILE *f, struct Email *e, bool user_hdr
 struct Body *mutt_read_mime_header(FILE *fp, bool digest)
 {
   struct Body *p = mutt_body_new();
+  struct Envelope *env = mutt_env_new();
   char *c = NULL;
   char *line = mutt_mem_malloc(LONG_STRING);
   size_t linelen = LONG_STRING;
@@ -1224,6 +1225,11 @@ struct Body *mutt_read_mime_header(FILE *fp, bool digest)
       }
     }
 #endif
+    else
+    {
+      if (mutt_rfc822_parse_line(env, NULL, line, c, false, false, false))
+        p->mime_headers = env;
+    }
   }
   p->offset = ftello(fp); /* Mark the start of the real data */
   if (p->type == TYPE_TEXT && !p->subtype)
@@ -1233,6 +1239,11 @@ struct Body *mutt_read_mime_header(FILE *fp, bool digest)
 
   FREE(&line);
 
+  if (p->mime_headers)
+    rfc2047_decode_envelope(p->mime_headers);
+  else
+    mutt_env_free(&env);
+
   return p;
 }
 
index ad0260782db245c3692802a245772f9661c44e09..5676e230db8bda8135dbe6042d51e1f81b04388a 100644 (file)
@@ -427,6 +427,7 @@ unsigned char *serial_dump_body(struct Body *c, unsigned char *d, int *off, bool
   nb.parts = NULL;
   nb.email = NULL;
   nb.aptr = NULL;
+  nb.mime_headers = NULL;
   nb.language = NULL;
 
   lazy_realloc(&d, *off + sizeof(struct Body));