+ if (q && *q) /* q is the dequoted value */
+ {
+ uschar * err_msg, * fname = q;
+ int slen;
+
+ /* build up an un-decoded filename over successive
+ filename*= parameters (for use when 2047 decode fails) */
+
+ mime_fname_rfc2231 = string_cat(mime_fname_rfc2231, q);
+
+ if (!decoding_failed)
+ {
+ if (!mime_filename_charset)
+ { /* try for RFC 2231 chset/lang */
+ uschar * s = q;
+
+ /* look for a ' in the raw paramval */
+ while(*s != '\'' && *s) s++; /* s is 1st ' or NUL */
+
+ if (*s) /* there was a ' */
+ {
+ int size;
+ if ((size = s-q) > 0)
+ mime_filename_charset = string_copyn(q, size);
+
+ if (*(fname = s)) fname++;
+ while(*fname == '\'') fname++; /*fname is after 2nd '*/
+ }
+ }
+
+ DEBUG(D_acl)
+ debug_printf_indent("MIME: charset %s fname '%s'\n",
+ mime_filename_charset ? mime_filename_charset : US"<NULL>",
+ fname);
+
+ fname = rfc2231_to_2047(fname, mime_filename_charset,
+ &slen);
+ DEBUG(D_acl)
+ debug_printf_indent("MIME: 2047-name %s\n", fname);
+
+ fname = rfc2047_decode(fname, FALSE, NULL, ' ',
+ NULL, &err_msg);
+ DEBUG(D_acl) debug_printf_indent(
+ "MIME: plain-name %s\n", fname);
+
+ if (!fname || Ustrlen(fname) == slen)
+ decoding_failed = TRUE;
+ else if (mp->value == &mime_filename)
+ {
+ /* build up a decoded filename over successive
+ filename*= parameters */
+
+ mime_fname = string_cat(mime_fname, fname);
+ mime_filename = string_from_gstring(mime_fname);
+ }
+ } /*!decoding_failed*/
+ } /*q*/
+
+ if (*p) p++; /* p is past ; */
+ goto param_done; /* done matching param names */
+ } /*2231 param coding extension*/