From: Kevin McCarthy Date: Sat, 1 Oct 2016 20:58:35 +0000 (-0700) Subject: RFC2047-decode mailto url headers after RFC2822 parsing. (closes #3879) X-Git-Tag: mutt-1-8-rel~130 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09e8be75da965a9b1b2e61609d26cb672618107c;p=mutt RFC2047-decode mailto url headers after RFC2822 parsing. (closes #3879) Commit 55819a7e6169 performed the RFC2047 decode before the parsing. This works okay for headers such as subject, but for others such as address fields could lead to parsing errors. Change to perform a decode on envelope headers after all the calls to mutt_parse_rfc822_line(), using the same list of fields as mutt_read_rfc822_header(). Change the do_2047 parameter of mutt_read_rfc822_line() to true, so that user headers are decoded if needed. --- diff --git a/url.c b/url.c index ee355a56..61742d01 100644 --- a/url.c +++ b/url.c @@ -305,22 +305,29 @@ int url_parse_mailto (ENVELOPE *e, char **body, const char *src) else { char *scratch; - char *decoded_value; size_t taglen = mutt_strlen (tag); - decoded_value = safe_strdup (value); - rfc2047_decode (&decoded_value); - - safe_asprintf (&scratch, "%s: %s", tag, decoded_value); + safe_asprintf (&scratch, "%s: %s", tag, value); scratch[taglen] = 0; /* overwrite the colon as mutt_parse_rfc822_line expects */ value = skip_email_wsp(&scratch[taglen + 1]); - mutt_parse_rfc822_line (e, NULL, scratch, value, 1, 0, 0, &last); - FREE (&decoded_value); + mutt_parse_rfc822_line (e, NULL, scratch, value, 1, 0, 1, &last); FREE (&scratch); } } } + /* 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); + rc = 0; out: