- while(*q != ';') q++;
- param_value_len = (q - (p + mp->namelen));
- param_value = (uschar *)malloc(param_value_len+1);
- memset(param_value,0,param_value_len+1);
- q = p + mp->namelen;
- Ustrncpy(param_value, q, param_value_len);
- param_value = rfc2047_decode(param_value, check_rfc2047_length, NULL, 32, ¶m_value_len, &q);
- debug_printf("Found %s MIME parameter in %s header, value is '%s'\n", mp->name, mime_header_list[i].name, param_value);
- *((uschar **)(mp->value)) = param_value;
- p += (mp->namelen + param_value_len + 1);
+ p += mp->namelen;
+ while(*p && *p != ';') /* ; terminates */
+ if (*p == '"')
+ {
+ p++; /* skip leading " */
+ while(*p && *p != '"') /* " protects ; */
+ param_value = string_cat(param_value, &size, &ptr, p++, 1);
+ if (*p) p++; /* skip trailing " */
+ }
+ else
+ param_value = string_cat(param_value, &size, &ptr, p++, 1);
+ if (*p) p++; /* skip trailing ; */
+
+ if (param_value)
+ {
+ uschar * dummy;
+ param_value[ptr++] = '\0';
+
+ param_value = rfc2047_decode(param_value,
+ check_rfc2047_length, NULL, 32, NULL, &dummy);
+ debug_printf(" Found %s MIME parameter in %s header, "
+ "value is '%s'\n", mp->name, mime_header_list[i].name,
+ param_value);
+ }
+ *mp->value = param_value;