From 66576f625749ee3cbd168604996d97cb33a58367 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Wed, 11 Jan 2017 21:37:52 -0500 Subject: [PATCH] Make sure we always generate a Content-ID header for message/external-body entities, as required by RFC 2045. --- docs/pending-release-notes | 2 ++ h/mhparse.h | 20 ++++++++++++++++++++ test/mhbuild/test-ext-params | 5 ++++- uip/mhbuildsbr.c | 6 ++++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/pending-release-notes b/docs/pending-release-notes index 52568c19..7de2628a 100644 --- a/docs/pending-release-notes +++ b/docs/pending-release-notes @@ -109,3 +109,5 @@ BUG FIXES - repl now make sure that any Fcc header in a replied-to message is not copied into the outgoing draft by default, and that the -fcc switch actually works in the absence of a Fcc header in the replied-to message. +- A Content-ID is generated for message/external-body entities as required + by RFC 2045, even if -nocontentid is supplied to mhbuild. diff --git a/h/mhparse.h b/h/mhparse.h index d184e530..3641f7a6 100644 --- a/h/mhparse.h +++ b/h/mhparse.h @@ -90,6 +90,26 @@ struct cefile { * A struct multipart contains (among other things) a linked list * of struct part elements, and THOSE contain a pointer to the sub-part's * Content structure. + * + * An extra note for message/external-body parts. The enclosing + * content structure is marked as a message/external-body; the c_ctparams + * contains a pointer to a struct exbody, which contains a pointer to + * (among other things) the "real" content (e.g., application/octet-stream). + * The "real" content structure has the c_ctexbody pointer back to the + * same struct exbody sees in the enclosing content structure (the struct + * exbody contains parent pointers if you need to traverse up the content + * structure). Hopefully this makes it clearer: + * + * Enclosing content: + * Type: message/external-body + * c_ctparams: pointer to "struct exbody" + * c_ctexbody: NULL + * + * "Real" content: + * Type: application/octet-stream (or whatever) + * c_ctparams: NULL + * c_ctexbody: pointer to "struct exbody" + * */ struct Content { /* source (read) file */ diff --git a/test/mhbuild/test-ext-params b/test/mhbuild/test-ext-params index 5be4514b..f3517166 100755 --- a/test/mhbuild/test-ext-params +++ b/test/mhbuild/test-ext-params @@ -241,13 +241,16 @@ Content-Type: message/external-body; access-type="url"; url*1="/that-should-be-wrapped/name.tar.gz" Content-Type: application/octet-stream +Content-ID: Content-Description: Test of a long URL Content-Disposition: attachment; filename="test.tar.gz" ------- =_aaaaaaaaaa0-- EOF -check "$draft" "$expected" +sed -e 's/^Content-ID:.*/Content-ID:/' "$draft" > "${draft}.nocontentid" + +check "${draft}.nocontentid" "$expected" [ ${failed:=0} -eq 0 ] && rm -f ${backup} diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 5607be17..2639043b 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -1725,9 +1725,11 @@ build_headers (CT ct, int header_encoding) add_header (ct, np, vp); /* - * output the Content-ID, unless disabled by -nocontentid + * output the Content-ID, unless disabled by -nocontentid. Note that + * RFC 2045 always requires a Content-ID header for message/external-body + * entities. */ - if (contentidsw && ct->c_id) { + if ((contentidsw || ct->c_ctexbody) && ct->c_id) { np = mh_xstrdup(ID_FIELD); vp = concat (" ", ct->c_id, NULL); add_header (ct, np, vp); -- 2.56.0