changeset: 6803:e0c0a2820b8b
user:      Kevin McCarthy <[email protected]>
date:      Sat Oct 01 13:58:35 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/e0c0a2820b8b

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.

diffs (40 lines):

diff -r 55819a7e6169 -r e0c0a2820b8b url.c
--- a/url.c     Tue Sep 27 18:15:25 2016 -0700
+++ b/url.c     Sat Oct 01 13:58:35 2016 -0700
@@ -305,22 +305,29 @@
       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:

Reply via email to