]> granicus.if.org Git - mutt/commitdiff
RFC2047-decode mailto url headers after RFC2822 parsing. (closes #3879)
authorKevin McCarthy <kevin@8t8.us>
Sat, 1 Oct 2016 20:58:35 +0000 (13:58 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sat, 1 Oct 2016 20:58:35 +0000 (13:58 -0700)
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.

url.c

diff --git a/url.c b/url.c
index ee355a56069b99acb10d1647efd84980eb5a2f3a..61742d0193786c1c04c85c258dfd20f66ed677b3 100644 (file)
--- 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: