From: Kevin McCarthy Date: Mon, 10 Dec 2018 03:52:21 +0000 (-0800) Subject: Factor out rfc2047_decode_envelope(). X-Git-Tag: mutt-1-12-rel~183 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67077f0dfb18a1d33a8a232b88c2102a6bb7812b;p=mutt Factor out rfc2047_decode_envelope(). --- diff --git a/parse.c b/parse.c index 75254958..af3911d9 100644 --- a/parse.c +++ b/parse.c @@ -1471,23 +1471,12 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs, hdr->content->hdr_offset = hdr->offset; hdr->content->offset = ftello (f); - /* do RFC2047 decoding */ - rfc2047_decode_adrlist (e->from); - rfc2047_decode_adrlist (e->to); - rfc2047_decode_adrlist (e->cc); - rfc2047_decode_adrlist (e->bcc); - rfc2047_decode_adrlist (e->reply_to); - rfc2047_decode_adrlist (e->mail_followup_to); - rfc2047_decode_adrlist (e->return_path); - rfc2047_decode_adrlist (e->sender); - rfc2047_decode (&e->x_label); + rfc2047_decode_envelope (e); if (e->subject) { regmatch_t pmatch[1]; - rfc2047_decode (&e->subject); - if (regexec (ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0) e->real_subj = e->subject + pmatch[0].rm_eo; else diff --git a/rfc2047.c b/rfc2047.c index ff5dc977..a19e01b3 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -948,3 +948,17 @@ void rfc2047_decode_adrlist (ADDRESS *a) a = a->next; } } + +void rfc2047_decode_envelope (ENVELOPE *e) +{ + rfc2047_decode_adrlist (e->from); + rfc2047_decode_adrlist (e->to); + rfc2047_decode_adrlist (e->cc); + rfc2047_decode_adrlist (e->bcc); + rfc2047_decode_adrlist (e->reply_to); + rfc2047_decode_adrlist (e->mail_followup_to); + rfc2047_decode_adrlist (e->return_path); + rfc2047_decode_adrlist (e->sender); + rfc2047_decode (&e->x_label); + rfc2047_decode (&e->subject); +} diff --git a/rfc2047.h b/rfc2047.h index 9e15d2f2..b61ab09e 100644 --- a/rfc2047.h +++ b/rfc2047.h @@ -27,3 +27,4 @@ void rfc2047_encode_adrlist (ADDRESS *, const char *); void rfc2047_decode (char **); void rfc2047_decode_adrlist (ADDRESS *); +void rfc2047_decode_envelope (ENVELOPE *); diff --git a/sendlib.c b/sendlib.c index 2128c94e..a0a4c21b 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2574,13 +2574,7 @@ void mutt_unprepare_envelope (ENVELOPE *env) rfc822_free_address (&env->mail_followup_to); /* back conversions */ - rfc2047_decode_adrlist (env->to); - rfc2047_decode_adrlist (env->cc); - rfc2047_decode_adrlist (env->bcc); - rfc2047_decode_adrlist (env->from); - rfc2047_decode_adrlist (env->reply_to); - rfc2047_decode (&env->subject); - rfc2047_decode (&env->x_label); + rfc2047_decode_envelope (env); } static int _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *resent_from, diff --git a/url.c b/url.c index d61e8d16..2d7c0b41 100644 --- a/url.c +++ b/url.c @@ -338,16 +338,7 @@ int url_parse_mailto (ENVELOPE *e, char **body, const char *src) } /* RFC2047 decode after the RFC822 parsing */ - rfc2047_decode_adrlist (e->from); - rfc2047_decode_adrlist (e->to); - rfc2047_decode_adrlist (e->cc); - rfc2047_decode_adrlist (e->bcc); - rfc2047_decode_adrlist (e->reply_to); - rfc2047_decode_adrlist (e->mail_followup_to); - rfc2047_decode_adrlist (e->return_path); - rfc2047_decode_adrlist (e->sender); - rfc2047_decode (&e->x_label); - rfc2047_decode (&e->subject); + rfc2047_decode_envelope (e); rc = 0;