-static void rfc2231_decode_one (char *dest, char *src)
-{
- char *d;
-
- for (d = dest; *src; src++) {
- if (*src == '%' &&
- isxdigit ((unsigned char) *(src + 1)) &&
- isxdigit ((unsigned char) *(src + 2))) {
- *d++ = (hexval (*(src + 1)) << 4) | (hexval (*(src + 2)));
- src += 2;
+ if (!headp)
+ return;
+
+ purge_empty_parameters (headp);
+
+ for (last = &head, p = *headp; p; p = q) {
+ q = p->next;
+
+ if (!(s = strchr (p->attribute, '*'))) {
+
+ /*
+ * Using RFC 2047 encoding in MIME parameters is explicitly
+ * forbidden by that document. Nevertheless, it's being
+ * generated by some software, including certain Lotus Notes to
+ * Internet Gateways. So we actually decode it.
+ */
+
+ if (option (OPTRFC2047PARAMS) && p->value && strstr (p->value, "=?"))
+ rfc2047_decode (&p->value);
+ else if (!option (OPTSTRICTMIME)) {
+ if (mime_which_token(AssumedCharset, -1) == MIME_US_ASCII)
+ mutt_convert_nonmime_string(&p->value);
+ }
+
+ *last = p;
+ last = &p->next;
+ p->next = NULL;
+ }
+ else if (*(s + 1) == '\0') {
+ *s = '\0';
+
+ s = rfc2231_get_charset (p->value, charset, sizeof (charset));
+ rfc2231_decode_one (p->value, s);
+ mutt_convert_string (&p->value, charset, Charset, M_ICONV_HOOK_FROM);
+
+ *last = p;
+ last = &p->next;
+ p->next = NULL;
+
+ dirty = 1;
+ }
+ else {
+ *s = '\0';
+ s++; /* let s point to the first character of idx. */
+ for (t = s; *t && isdigit ((unsigned char) *t); t++);
+ encoded = (*t == '*');
+ *t = '\0';
+
+ idx = atoi (s);
+
+ conttmp = rfc2231_param_new ();
+ conttmp->attribute = p->attribute;
+ conttmp->value = p->value;
+ conttmp->encoded = encoded;
+ conttmp->idx = idx;
+
+ p->attribute = NULL;
+ p->value = NULL;
+ p_delete(&p);
+
+ rfc2231_list_insert (&conthead, conttmp);
+ }