- LIST *uh = UserHeader;
- LIST *last = env->userhdrs;
-
- if (last)
- while (last->next)
- last = last->next;
-
- for (; uh; uh = uh->next)
- {
- if (ascii_strncasecmp ("from:", uh->data, 5) == 0)
- {
- /* User has specified a default From: address. Remove default address */
- rfc822_free_address (&env->from);
- env->from = rfc822_parse_adrlist (env->from, uh->data + 5);
- }
- else if (ascii_strncasecmp ("reply-to:", uh->data, 9) == 0)
- {
- rfc822_free_address (&env->reply_to);
- env->reply_to = rfc822_parse_adrlist (env->reply_to, uh->data + 9);
- }
- else if (ascii_strncasecmp ("message-id:", uh->data, 11) == 0)
- mutt_str_replace (&env->message_id, uh->data + 11);
- else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 &&
- ascii_strncasecmp ("cc:", uh->data, 3) != 0 &&
- ascii_strncasecmp ("bcc:", uh->data, 4) != 0 &&
+ string_list_t *uh;
+ string_list_t **last = string_list_last(&env->userhdrs);
+
+ for (uh = UserHeader; uh; uh = uh->next) {
+ const char *p = strchr(uh->data, ':');
+ if (!p)
+ continue;
+
+ switch (mime_which_token(uh->data, p++ - uh->data)) {
+ case MIME_FROM:
+ /* User has specified a default From: address. Remove default address */
+ address_list_wipe(&env->from);
+ env->from = rfc822_parse_adrlist(env->from, p);
+ break;
+
+ case MIME_REPLY_TO:
+ address_list_wipe(&env->reply_to);
+ env->reply_to = rfc822_parse_adrlist (env->reply_to, p);
+ break;
+
+ case MIME_MESSAGE_ID:
+ m_strreplace(&env->message_id, p);
+ break;
+
+ case MIME_TO:
+ case MIME_CC:
+ case MIME_BCC: