From bee5b805ad63b1b56b20b9efa2bd90b2a7f92d97 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Mon, 18 Feb 2002 14:55:31 +0000 Subject: [PATCH] Fix for #1047. From Michael Elkins. --- alias.c | 4 ++-- send.c | 32 ++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/alias.c b/alias.c index 777c0aea..cd037217 100644 --- a/alias.c +++ b/alias.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1996-2002 Michael R. Elkins * * 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 a0c595e8..d905304d 100644 --- a/send.c +++ b/send.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1996-2002 Michael R. Elkins * * 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: */ -- 2.40.0