From: David Levine Date: Thu, 15 May 2014 15:28:03 +0000 (-0500) Subject: Added support for mhbuild-disposition-[/] profile X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/07a260ff4749449f6618358c2d756ae3f5168619?hp=252f672ba218d1ed1f5018844dd007b5d2e6a860 Added support for mhbuild-disposition-[/] profile entries when mhbuild expands Attach: headers. Default to 'attachment', but override with 'inline' entries for text/calendar and message/rfc822 in mhn.defaults. --- diff --git a/etc/mhn.defaults.sh b/etc/mhn.defaults.sh index cff0e702..15be57d1 100755 --- a/etc/mhn.defaults.sh +++ b/etc/mhn.defaults.sh @@ -124,6 +124,17 @@ elif [ -f "/dev/audio" ]; then fi fi +#### +#### mhbuild-disposition-[/] entries are used by the +#### WhatNow attach for deciding whether the Content-Disposition +#### should be 'attachment' or 'inline'. Only those values are +#### supported. +#### +cat <> ${TMP} +mhbuild-disposition-text/calendar: inline +mhbuild-disposition-message/rfc822: inline +EOF + PGM="`$SEARCHPROG $SEARCHPATH mpeg_play`" if [ ! -z "$PGM" ]; then echo "mhshow-show-video/mpeg: %p$PGM %f" >> $TMP diff --git a/man/mhbuild.man b/man/mhbuild.man index 4a0e8730..dc47b63c 100644 --- a/man/mhbuild.man +++ b/man/mhbuild.man @@ -102,6 +102,23 @@ content specified by directives (see below). See .IR send (1) for more details. +.PP +By default, the Content-Disposition will be \*(lqattachment\*(rq. +.B mhbuild +looks for user profile and mhn.defaults entries of the form +.PP +.RS 5 +mhbuild-disposition-/ +.RE +or +.RS 5 +mhbuild-disposition- +.RE +.PP +to supply the disposition value. The only supported values are +.I attachment +and +.IR inline. .SS "Translating the Composition File" .B mhbuild is essentially a filter to aid in the composition of MIME diff --git a/man/send.man b/man/send.man index 66b00553..c8346c34 100644 --- a/man/send.man +++ b/man/send.man @@ -156,6 +156,10 @@ Content-Description: VERSION Content-Disposition: attachment; filename="VERSION" .fi .PP +See +.IR mhbuild (1) +for explanation of how the Content-Disposition value is selected. +.PP If .B \-push is specified, @@ -466,6 +470,7 @@ for more information. .IR dist (1), .IR file (1), .IR forw (1), +.IR mhbuild (1), .IR mhparam (1), .IR repl (1), .IR whatnow (1), diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 3cdea761..3429c1ef 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -1856,6 +1856,8 @@ setup_attach_content(CT ct, char *filename) char *type, *simplename = r1bindex(filename, '/'); struct str2init *s2i; PM pm; + char buffer[BUFSIZ], *cp; + int no_subtype = 0; if (! (type = mime_type(filename))) { adios(NULL, "Unable to determine MIME type of \"%s\"", filename); @@ -1929,14 +1931,36 @@ setup_attach_content(CT ct, char *filename) ct->c_cefile.ce_file = getcpy(filename); /* - * If it's a text/calendar, we need to make sure it's an inline, - * otherwise it won't work with some calendar programs. Otherwise - * assume attachment + * Look for mhbuild-disposition-/ entry + * that specifies Content-Disposition type. Only + * 'attachment' and 'inline' are allowed. Default to + * 'attachment'. */ - if (strcasecmp(ct->c_ctinfo.ci_type, "text") == 0 && - strcasecmp(ct->c_ctinfo.ci_subtype, "calendar") == 0) { - ct->c_dispo_type = getcpy("inline"); + snprintf (buffer, sizeof(buffer), "%s-disposition-%s/%s", + invo_name, ct->c_ctinfo.ci_type, ct->c_ctinfo.ci_subtype); + cp = context_find (buffer); + if (cp == NULL || *cp == '\0') { + no_subtype = 1; + snprintf (buffer, sizeof(buffer), "%s-disposition-%s", invo_name, + ct->c_ctinfo.ci_type); + cp = context_find (buffer); + } + if (cp != NULL && *cp != '\0') { + if (strcasecmp (cp, "attachment") && + strcasecmp (cp, "inline")) { + admonish (NULL, "configuration problem: %s-disposition-%s%s%s " + "specifies '%s' but only 'attachment' and 'inline' are " + "allowed", invo_name, + ct->c_ctinfo.ci_type, + no_subtype ? "" : "/", + no_subtype ? "" : ct->c_ctinfo.ci_subtype, + cp); + } + } + + if (cp) { + ct->c_dispo_type = getcpy(cp); } else { ct->c_dispo_type = getcpy("attachment"); }