+ /*
+ * If there's a Content-Disposition header and it has a filename,
+ * use that (RFC-2183).
+ */
+ if (ct->c_dispo) {
+ char *cp = strchr (ct->c_dispo, ';');
+ CI ci = calloc (1, sizeof *ci);
+ int status;
+ int found_filename = 0;
+
+ if (cp && parse_header_attrs (ct->c_file, strlen (invo_name) + 2, &cp,
+ ci, &status) == OK) {
+ for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
+ if (! strcasecmp (*ap, "filename")
+ && *(cp = *ep) != '/'
+ && *cp != '.'
+ && *cp != '|'
+ && *cp != '!'
+ && !strchr (cp, '%')) {
+ ct->c_storeproc = add (cp, NULL);
+ found_filename = 1;
+ }
+ free (*ap);
+ }
+ }
+
+ free (ci);
+ if (found_filename) return;
+ }
+