{
t->subtype = safe_strdup ("pgp-signature");
t->use_disp = 0;
- t->disposition = DISPINLINE;
+ t->disposition = DISPNONE;
t->encoding = ENC7BIT;
}
t->filename = sigfile;
t->parts->next->encoding = ENC7BIT;
t->parts->next->filename = outfile;
t->parts->next->use_disp = 1;
- t->parts->next->disposition = DISPINLINE;
+ t->parts->next->disposition = DISPATTACH;
t->parts->next->unlink = 1; /* delete after sending the message */
t->parts->next->d_filename = safe_strdup ("msg.asc"); /* non pgp/mime
can save */
{
DISPINLINE,
DISPATTACH,
- DISPFORMDATA
+ DISPFORMDATA,
+ DISPNONE /* no preferred disposition */
};
/* MIME encoding/decoding global vars */
t->subtype = safe_strdup ("pgp-signature");
t->filename = safe_strdup (sigfile);
t->use_disp = 0;
- t->disposition = DISPINLINE;
+ t->disposition = DISPNONE;
t->encoding = ENC7BIT;
t->unlink = 1; /* ok to remove this file after sending. */
t->parts->next->encoding = ENC7BIT;
t->parts->next->filename = safe_strdup (tempfile);
t->parts->next->use_disp = 1;
- t->parts->next->disposition = DISPINLINE;
+ t->parts->next->disposition = DISPATTACH;
t->parts->next->unlink = 1; /* delete after sending the message */
t->parts->next->d_filename = safe_strdup ("msg.asc"); /* non pgp/mime can save */
#endif
- b->disposition = DISPINLINE;
+ b->disposition = DISPNONE;
b->unlink = 1;
b->noconv = 1;
case 'I':
if (!optional)
{
- snprintf (dest, destlen, "%c",
- (aptr->content->disposition == DISPINLINE) ? 'I' : 'A');
+ const char dispchar[] = { 'I', 'A', 'F', '-' };
+ char ch;
+
+ if (aptr->content->disposition < sizeof(dispchar))
+ ch = dispchar[aptr->content->disposition];
+ else
+ {
+ dprint(1, (debugfile, "ERROR: invalid content-disposition %d\n", aptr->content->disposition));
+ ch = '!';
+ }
+ snprintf (dest, destlen, "%c", ch);
}
break;
case 'm':
extern char RFC822Specials[];
-#define DISPOSITION(X) X==DISPATTACH?"attachment":"inline"
-
const char MimeSpecials[] = "@.,;:<>[]\\\"()?/= \t";
char B64Chars[64] = {
if (a->description)
fprintf(f, "Content-Description: %s\n", a->description);
- fprintf (f, "Content-Disposition: %s", DISPOSITION (a->disposition));
-
- if (a->use_disp)
+ if (a->disposition != DISPNONE)
{
- if(!(fn = a->d_filename))
- fn = a->filename;
+ const char *dispstr[] = {
+ "inline",
+ "attachment",
+ "form-data"
+ };
- if (fn)
+ if (a->disposition < sizeof(dispstr)/sizeof(char*))
{
- char *tmp;
+ fprintf (f, "Content-Disposition: %s", dispstr[a->disposition]);
- /* Strip off the leading path... */
- if ((t = strrchr (fn, '/')))
- t++;
- else
- t = fn;
+ if (a->use_disp)
+ {
+ if (!(fn = a->d_filename))
+ fn = a->filename;
- buffer[0] = 0;
- tmp = safe_strdup (t);
- encode = rfc2231_encode_string (&tmp);
- rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials);
- FREE (&tmp);
- fprintf (f, "; filename%s=%s", encode ? "*" : "", buffer);
+ if (fn)
+ {
+ char *tmp;
+
+ /* Strip off the leading path... */
+ if ((t = strrchr (fn, '/')))
+ t++;
+ else
+ t = fn;
+
+ buffer[0] = 0;
+ tmp = safe_strdup (t);
+ encode = rfc2231_encode_string (&tmp);
+ rfc822_cat (buffer, sizeof (buffer), tmp, MimeSpecials);
+ FREE (&tmp);
+ fprintf (f, "; filename%s=%s", encode ? "*" : "", buffer);
+ }
+ }
+
+ fputc ('\n', f);
+ }
+ else
+ {
+ dprint(1, (debugfile, "ERROR: invalid content-disposition %d\n", a->disposition));
}
}
- fputc ('\n', f);
-
if (a->encoding != ENC7BIT)
fprintf(f, "Content-Transfer-Encoding: %s\n", ENCODING (a->encoding));