X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/bcb443a54dc3e08c2aa51fa1dd414cf2023fc037..821f3da0f61239ec5990c105e77aacc7638e45eb:/uip/mhoutsbr.c diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index 59bf7a42..1064b15e 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -83,6 +83,14 @@ output_content (CT ct, FILE *out) { int result = 0; CI ci = &ct->c_ctinfo; + char *boundary = ci->ci_values[0], **ap, **vp; + + for (ap = ci->ci_attrs, vp = ci->ci_values; *ap; ++ap, ++vp) { + if (! mh_strcasecmp ("boundary", *ap)) { + boundary = *vp; + break; + } + } /* * Output all header fields for this content @@ -110,14 +118,23 @@ output_content (CT ct, FILE *out) putc ('\n', out); m = (struct multipart *) ct->c_ctparams; + + if (m->mp_content_before) { + fprintf (out, "%s", m->mp_content_before); + } + for (part = m->mp_parts; part; part = part->mp_next) { CT p = part->mp_part; - fprintf (out, "\n--%s\n", ci->ci_values[0]); + fprintf (out, "\n--%s\n", boundary); if (output_content (p, out) == NOTOK) return NOTOK; } - fprintf (out, "\n--%s--\n", ci->ci_values[0]); + fprintf (out, "\n--%s--\n", boundary); + + if (m->mp_content_after) { + fprintf (out, "%s", m->mp_content_after); + } } break; @@ -144,7 +161,14 @@ output_content (CT ct, FILE *out) default: switch (ct->c_encoding) { case CE_7BIT: - putc ('\n', out); + /* Special case: if this is a non-MIME message with no + body, don't emit the newline that would appear between + the headers and body. In that case, the call to + write8Bit() shouldn't be needed, but is harmless. */ + if (ct->c_ctinfo.ci_attrs[0] != NULL || + ct->c_begin != ct->c_end) { + putc ('\n', out); + } result = write8Bit (ct, out); break;