int get_ctinfo(unsigned char *, CT, int);
int open7Bit(CT, char **);
void close_encoding(CT);
+char *extract_name_value(char *, char *);
** one, return the entire value. Note that, for example, a name_suffix
** of name will match filename="foo", and return foo.
*/
-static char *
+char *
extract_name_value(char *name_suffix, char *value) {
char *extracted_name_value = value;
char *name_suffix_plus_quote = concat(name_suffix, "=\"", NULL);
static int
store_generic(CT ct)
{
- char **ap, **vp, *cp;
+ char **ap, **vp, *cp, *filename;
CI ci = &ct->c_ctinfo;
/*
** (only the "message" subtype "rfc822" will use store_generic).
*/
if (autosw && ct->c_type != CT_MESSAGE) {
+ /* First check for "filename" in Content-Disposition header */
+ filename = extract_name_value("filename", ct->c_dispo);
+ if (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
}
}
+finished:
return store_content(ct, NULL);
}