+ if (autosw && ct->c_type != CT_MESSAGE) {
+ /* First check for "filename" in Content-Disposition header */
+ filename = extract_name_value("filename", ct->c_dispo);
+ if (filename && strcmp(filename, ct->c_dispo)!=0) {
+ /* We found "filename" */
+ cp = mhbasename(filename);
+ if (*cp && *cp!='.' && *cp!='|' && *cp!='!' &&
+ !strchr(cp, '%')) {
+ /* filename looks good: use it */
+ ct->c_storeproc = mh_xstrdup(cp);
+ goto finished;
+ }
+ }
+ /*
+ ** Check the attribute/value pairs, for the attribute "name".
+ ** If found, take the basename, do a few sanity checks and
+ ** copy the value into c_storeproc.
+ */
+ for (ap = ci->ci_attrs, vp = ci->ci_values; *ap; ap++,vp++) {
+ if (mh_strcasecmp(*ap, "name")!=0) {
+ continue;
+ }
+ cp = mhbasename(*vp);
+ if (*cp && *cp!='.' && *cp!='|' && *cp!='!' &&
+ !strchr(cp, '%')) {
+ /* filename looks good: use it */
+ ct->c_storeproc = mh_xstrdup(cp);
+ }
+ break;
+ }
+ }