From c253cb98e5ec6559abb87f43e69319f05699358f Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Thu, 15 Nov 2007 12:32:04 +0100 Subject: [PATCH] Properly parse and validate Message-IDs from my_hdrs. Closes #2452. --- parse.c | 4 ++-- protos.h | 2 ++ send.c | 10 +++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/parse.c b/parse.c index 8cf545305..9e5fc4c8a 100644 --- a/parse.c +++ b/parse.c @@ -926,7 +926,7 @@ time_t mutt_parse_date (const char *s, HEADER *h) } /* extract the first substring that looks like a message-id */ -static char *extract_message_id (const char *s) +char *mutt_extract_message_id (const char *s) { const char *p; char *r; @@ -1132,7 +1132,7 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short { /* We add a new "Message-ID:" when building a message */ FREE (&e->message_id); - e->message_id = extract_message_id (p); + e->message_id = mutt_extract_message_id (p); matched = 1; } else if (!ascii_strncasecmp (line + 1, "ail-", 4)) diff --git a/protos.h b/protos.h index 43115963e..675a6cd08 100644 --- a/protos.h +++ b/protos.h @@ -90,6 +90,8 @@ void set_quadoption (int, int); int query_quadoption (int, const char *); int quadoption (int); +char* mutt_extract_message_id (const char *); + ADDRESS *mutt_default_from (void); ADDRESS *mutt_get_address (ENVELOPE *, char **); ADDRESS *mutt_lookup_alias (const char *s); diff --git a/send.c b/send.c index 5ae2bda5c..0c2b44265 100644 --- a/send.c +++ b/send.c @@ -298,7 +298,15 @@ static void process_user_header (ENVELOPE *env) 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); + { + char *tmp = mutt_extract_message_id (uh->data + 11); + if (rfc822_valid_msgid (tmp) >= 0) + { + FREE(&env->message_id); + env->message_id = tmp; + } else + FREE(&tmp); + } else if (ascii_strncasecmp ("to:", uh->data, 3) != 0 && ascii_strncasecmp ("cc:", uh->data, 3) != 0 && ascii_strncasecmp ("bcc:", uh->data, 4) != 0 && -- 2.50.0