From: Mads Martin Joergensen <mmj@mmj.dk>
To: mlmmj@mlmmj.org
Subject: Re: Fw: footer isn't appended to multipart messages (part II: reality check!)
Date: Mon, 10 Oct 2005 05:28:43 +0000 [thread overview]
Message-ID: <20051010052843.GE17022@mmj.dk> (raw)
In-Reply-To: <200507052130.02825.lists@seattleserver.com>
* Jakob Hirsch <jh@plonk.de> [Oct 09. 2005 21:11]:
> > Also those who are running patched versions, please please download this
> > tar-ball and make sure your patches are folded in.
>
> Um, you didn't like my footer-mime patch? I didn't get any comments,
> so I wonder what's wrong about it.
Well, if someone wants to add a footer, then every single mail will be
"massaged" even in the case of it not being needed. I really would like
it to happen only when the mail is not a text mail.
I also would like to see some checking of the writen() return values. If
any one these writes fail, it just continues on.
* Jakob Hirsch <jh@plonk.de> [Jul 20. 2005 00:09]:
> --- mlmmj-1.2.8/src/do_all_the_voodo_here.c 2005-05-09 14:50:15.000000000 +0200
> +++ mlmmj-1.2.8-jh4/src/do_all_the_voodo_here.c 2005-07-19 23:55:32.000000000 +0200
> @@ -79,9 +79,12 @@
> const char **delhdrs, struct mailhdr *readhdrs,
> struct strlist *allhdrs, const char *prefix)
> {
> - char *hdrline, *subject, *unqp;
> + char *hdrline, *subject, *unqp, *buf;
> int hdrsadded = 0;
> int subject_present = 0;
> + char *content_type_orig = NULL; /* original Content-Type header */
> + char *content_te_orig = NULL; /* original Content-Transfer-Encoding */
> + char *boundary = NULL;
>
> allhdrs->count = 0;
> allhdrs->strs = NULL;
> @@ -116,7 +119,22 @@
> myfree(subject);
> subject_present = 1;
> }
> -
> +
> + /* time to add Content-Type */
> + if (content_type_orig || content_te_orig) {
> + /* create new boundary for MIME-encapsulation */
> + buf = random_str();
> + boundary = concatstr(3, "=_=", buf, "=_=");
> + myfree(buf);
> +
> + /* and create new content-type header */
> + buf = concatstr(3,
> + "Content-Type: multipart/mixed; boundary=\"",
> + boundary, "\"\n");
> + writen(outfd, buf, strlen(buf));
> + myfree(buf);
> + }
> +
> if(writen(outfd, hdrline, strlen(hdrline))
> < 0) {
> myfree(hdrline);
> @@ -159,7 +177,25 @@
> myfree(unqp);
> }
> }
> -
> +
> + if (footfd>=0) {
> + /* save MIME header for later use */
> + if (!strncasecmp(hdrline, "Content-Type:", 13)) {
> + if (!content_type_orig)
> + content_type_orig = hdrline;
> + else
> + myfree(hdrline); /* drop surplus */
> + continue;
> + } else if (!strncasecmp(hdrline,
> + "Content-Transfer-Encoding:", 26)) {
> + if (!content_te_orig)
> + content_te_orig = hdrline;
> + else
> + myfree(hdrline); /* drop surplus */
> + continue;
> + }
> + }
> +
> /* Should it be stripped? */
> if(delhdrs) {
> if(!findit(hdrline, delhdrs))
> @@ -170,20 +206,64 @@
>
> myfree(hdrline);
> }
> +
> + if (content_type_orig || content_te_orig) {
>
> - /* Just print the rest of the mail */
> - if(dumpfd2fd(infd, outfd) < 0) {
> - log_error(LOG_ARGS, "Error when dumping rest of mail");
> - return -1;
> - }
> + buf = concatstr(3,
> + "This is a multi-part message in MIME format.\n\n--",
> + boundary, "\n");
> + writen(outfd, buf, strlen(buf));
> + myfree(buf);
> +
> + if (content_type_orig) {
> + writen(outfd, content_type_orig, strlen(content_type_orig));
> + myfree(content_type_orig);
> + }
> +
> + if (content_te_orig) {
> + writen(outfd, content_te_orig, strlen(content_te_orig));
> + myfree(content_te_orig);
> + }
> +
> + writen(outfd, "\n", 1);
>
> - /* No more, lets add the footer if one */
> - if(footfd >= 0)
> + /* Just print the rest of the mail */
> + if(dumpfd2fd(infd, outfd) < 0) {
> + log_error(LOG_ARGS, "Error when dumping rest of mail");
> + return -1;
> + }
> +
> + buf = concatstr(3, "\n--", boundary,
> + "\nContent-Type: text/plain\nContent-Disposition: inline\n\n");
> + writen(outfd, buf, strlen(buf));
> + myfree(buf);
> +
> + /* No more, lets add the footer if one */
> if(dumpfd2fd(footfd, outfd) < 0) {
> log_error(LOG_ARGS, "Error when adding footer");
> return -1;
> }
>
> + buf = concatstr(3, "\n--", boundary, "--\n");
> + myfree(boundary);
> + writen(outfd, buf, strlen(buf));
> + myfree(buf);
> +
> + } else {
> + /* Just print the rest of the mail */
> + if(dumpfd2fd(infd, outfd) < 0) {
> + log_error(LOG_ARGS, "Error when dumping rest of mail");
> + return -1;
> + }
> +
> + /* No more, lets add the footer if one */
> + if(footfd >= 0)
> + if(dumpfd2fd(footfd, outfd) < 0) {
> + log_error(LOG_ARGS, "Error when adding footer");
> + return -1;
> + }
> + }
> +
> fsync(outfd);
>
> return 0;
--
Mads Martin Joergensen, http://mmj.dk
"Why make things difficult, when it is possible to make them cryptic
and totally illogical, with just a little bit more effort?"
-- A. P. J.
next prev parent reply other threads:[~2005-10-10 5:28 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-05 21:30 footer isn't appended to multipart messages Casey Allen Shobe
2005-07-05 22:09 ` Sven 'Darkman' Michels
2005-07-05 23:32 ` footer isn't appended to multipart messages (part II: reality check!) Patrick Bennett
2005-07-06 2:38 ` Casey Allen Shobe
2005-07-06 6:17 ` Fw: " Patrick Bennett
2005-07-06 8:05 ` footer isn't appended to multipart messages Mads Martin Joergensen
2005-07-06 8:12 ` footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-07-06 8:15 ` Mads Martin Joergensen
2005-07-06 13:00 ` Fw: " Morten K. Poulsen
2005-07-07 15:31 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-07-07 16:07 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-07-09 18:10 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-07-15 14:29 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-07-16 13:12 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-07-16 14:52 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-07-18 9:49 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-07-18 18:12 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-07-18 23:26 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-07-19 7:25 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-07-19 7:59 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-07-19 8:05 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-07-19 18:44 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-07-19 22:09 ` Jakob Hirsch
2005-07-20 6:18 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-10-10 5:28 ` Mads Martin Joergensen [this message]
2005-10-10 21:41 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-10-10 21:47 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Neale Pickett
2005-10-10 22:08 ` Fw: footer isn't appended to multipart messages (part II: reality Jakob Hirsch
2005-10-11 0:15 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-10-11 3:06 ` Neale Pickett
2005-10-11 7:52 ` Fw: footer isn't appended to multipart messages (part II: Jakob Hirsch
2005-10-11 8:52 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-10-11 9:30 ` Fw: footer isn't appended to multipart messages (part II: Jakob Hirsch
2005-10-11 12:24 ` Fw: footer isn't appended to multipart messages (part II: reality check!) Mads Martin Joergensen
2005-10-11 12:55 ` Neale Pickett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051010052843.GE17022@mmj.dk \
--to=mmj@mmj.dk \
--cc=mlmmj@mlmmj.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.