- 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));