]> granicus.if.org Git - mutt/commitdiff
Fix for #1047. From Michael Elkins.
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 18 Feb 2002 14:55:31 +0000 (14:55 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 18 Feb 2002 14:55:31 +0000 (14:55 +0000)
alias.c
send.c

diff --git a/alias.c b/alias.c
index 777c0aea3dab7949a771b4fd3e4f0c27faeef858..cd0372170debe4895d5f7c2c6b9619ef6f4b9eaf 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
+ * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
  * 
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -124,7 +124,7 @@ ADDRESS *mutt_expand_aliases (ADDRESS *a)
 
   t = mutt_expand_aliases_r (a, &expn);
   mutt_free_list (&expn);
-  return (t);
+  return (mutt_remove_duplicates (t));
 }
 
 void mutt_expand_aliases_env (ENVELOPE *env)
diff --git a/send.c b/send.c
index a0c595e8f9d5a8917e501015ba22dc0a78b109bc..d905304d32ea782755c39c4691f704f4730db356 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
+ * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
  * 
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -563,6 +563,8 @@ LIST *mutt_make_references(ENVELOPE *e)
 
 void mutt_fix_reply_recipients (ENVELOPE *env)
 {
+  mutt_expand_aliases_env (env);
+
   if (! option (OPTMETOO))
   {
     /* the order is important here.  do the CC: first so that if the
@@ -700,7 +702,6 @@ envelope_defaults (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, int flags)
       return (-1);
     }
 
-    mutt_fix_reply_recipients (env);
     mutt_make_misc_reply_headers (env, ctx, cur, curenv);
     mutt_make_reference_headers (tag ? NULL : curenv, env, ctx);
   }
@@ -1067,11 +1068,12 @@ ci_send_message (int flags,             /* send mode */
     signas = safe_strdup(PgpSignAs);
 #endif /* HAVE_PGP */
 
-  if (msg)
-  {
-    mutt_expand_aliases_env (msg->env);
-  }
-  else
+  /* Delay expansion of aliases until absolutely necessary--shouldn't
+   * be necessary unless we are prompting the user or about to execute a
+   * send-hook.
+   */
+
+  if (!msg)
   {
     msg = mutt_new_header ();
 
@@ -1134,7 +1136,15 @@ ci_send_message (int flags,              /* send mode */
     /* we shouldn't have to worry about freeing `msg->env->from' before
      * setting it here since this code will only execute when doing some
      * sort of reply.  the pointer will only be set when using the -H command
-     * line option */
+     * line option.
+     *
+     * We shouldn't have to worry about alias expansion here since we are
+     * either replying to a real or postponed message, therefore no aliases
+     * should exist since the user has not had the opportunity to add
+     * addresses to the list.  We just have to ensure the postponed messages
+     * have their aliases expanded.
+     */
+
     msg->env->from = set_reverse_name (cur->env);
   }
 
@@ -1149,6 +1159,7 @@ ci_send_message (int flags,               /* send mode */
       process_user_recips (msg->env);
       process_user_header (msg->env);
     }
+    mutt_expand_aliases_env (msg->env);
   }
   else if (! (flags & (SENDPOSTPONED|SENDRESEND)))
   {
@@ -1159,6 +1170,9 @@ ci_send_message (int flags,               /* send mode */
     if (option (OPTHDRS))
       process_user_recips (msg->env);
 
+    /* Expand aliases and remove duplicates/crossrefs */
+    mutt_fix_reply_recipients (msg->env);
+
     if (! (flags & SENDMAILX) &&
        ! (option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
        ! ((flags & SENDREPLY) && option (OPTFASTREPLY)))
@@ -1619,3 +1633,5 @@ cleanup:
   return rv;
 
 }
+
+/* vim: set sw=2: */