- 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);
-
- temp_string = rfc2231_to_2047(fname, mime_filename_charset,
- &slen);
- DEBUG(D_acl)
- debug_printf_indent("MIME: 2047-name %s\n", temp_string);
-
- temp_string = rfc2047_decode(temp_string, FALSE, NULL, ' ',
- NULL, &err_msg);
- DEBUG(D_acl)
- debug_printf_indent("MIME: plain-name %s\n", temp_string);
-
- if (!temp_string || (size = Ustrlen(temp_string)) == slen)
- decoding_failed = TRUE;
- else
- /* build up a decoded filename over successive
- filename*= parameters */
-
- mime_filename = mime_fname = mime_fname
- ? string_sprintf("%s%s", mime_fname, temp_string)
- : temp_string;
- } /*!decoding_failed*/
- } /*q*/
- } /*2231 filename*/
-
- else
- /* look for interesting parameters */
- for (mime_parameter * mp = mime_parameter_list;
- mp < mime_parameter_list + nelem(mime_parameter_list);
- mp++
- ) if (strncmpic(mp->name, p, mp->namelen) == 0)
- {
- uschar * q;
- uschar * dummy_errstr;
+ 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*/
+ }
+ else if (*p == '=')
+ { /* non-2231 param */
+ uschar * q, * dummy_errstr;