nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] flattening continuation lines

2005-04-18 03:57:41
Paul Fox wrote:
i have what feels like a simple problem.

i want to post-process the output of mhbuild to add a "Content-disposition"
header after any Content-type header that matches some criteria.

Wouldn't it be easier to just edit the C code? Out of interest, why do
you want to do this? Are you perhaps sending mail to someone whose mail
client doesn't like messages which lack the header? mhbuild probably
ought to handle Content-Disposition. The existance (or otherwise) of a
filename is perhaps a good way to select whether ot not the value should
be inline or attachment.

A quick one-minute hack at the C code is below. I've not searched out
the relevant rfc or anything so all this is is something to start with.
I suspect their are some situations (such as multipart parts) where you
don't want it, for example.

Oliver

Index: h/mime.h
===================================================================
RCS file: /cvsroot/nmh/nmh/h/mime.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mime.h
--- h/mime.h    30 Apr 1999 18:08:34 -0000      1.1.1.1
+++ h/mime.h    18 Apr 2005 10:23:52 -0000
@@ -12,6 +12,7 @@
 #define        ENCODING_FIELD  "Content-Transfer-Encoding"
 #define        ID_FIELD        "Content-ID"
 #define        DESCR_FIELD     "Content-Description"
+#define        DISP_FIELD      "Content-Disposition"
 #define        MD5_FIELD       "Content-MD5"
 
 #define        isatom(c)   (!isspace (c) && !iscntrl (c) && (c) != '(' \
Index: uip/mhbuildsbr.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/mhbuildsbr.c,v
retrieving revision 1.9
diff -u -r1.9 mhbuildsbr.c
--- uip/mhbuildsbr.c    30 Sep 2003 16:58:43 -0000      1.9
+++ uip/mhbuildsbr.c    18 Apr 2005 10:23:52 -0000
@@ -3845,6 +3845,7 @@
 build_headers (CT ct)
 {
     int        cc, mailbody, len;
+    int nameattr = 0;
     char **ap, **ep;
     char *np, *vp, buffer[BUFSIZ];
     CI ci = &ct->c_ctinfo;
@@ -3901,6 +3902,7 @@
        vp = add (";", vp);
        len++;
 
+        if (!strcasecmp(*ap, "name")) nameattr = 1;
        snprintf (buffer, sizeof(buffer), "%s=\"%s\"", *ap, *ep);
        if (len + 1 + (cc = strlen (buffer)) >= CPERLIN) {
            vp = add ("\n\t", vp);
@@ -3949,6 +3951,13 @@
        vp = concat (" ", ct->c_descr, NULL);
        add_header (ct, np, vp);
     }
+
+    /*
+     * output Content-Disposition
+     */
+    np = add (DISP_FIELD, NULL);
+    vp = concat (" ", nameattr ? "attachment\n" : "inline\n", NULL);
+    add_header (ct, np, vp);
 
 skip_headers:
     /*


_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
http://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>