From fb6b8301237bcdd72bb86d34af68f378a07e4d70 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Wed, 21 Dec 2016 15:38:11 -0500 Subject: [PATCH] Make the -fcc switch to repl actually work properly, and make sure that any Fcc header in a replied-to message is not carried over to the draft. --- docs/pending-release-notes | 3 ++ test/repl/test-repl | 60 ++++++++++++++++++++++++++++++++++++-- uip/replsbr.c | 29 +++++++++++------- 3 files changed, 79 insertions(+), 13 deletions(-) diff --git a/docs/pending-release-notes b/docs/pending-release-notes index 838ae10b..52568c19 100644 --- a/docs/pending-release-notes +++ b/docs/pending-release-notes @@ -106,3 +106,6 @@ BUG FIXES header, not just those with a character set not specified. - mhbuild no longer parses lines that start with # as directives with -nodirectives. +- repl now make sure that any Fcc header in a replied-to message is not + copied into the outgoing draft by default, and that the -fcc switch + actually works in the absence of a Fcc header in the replied-to message. diff --git a/test/repl/test-repl b/test/repl/test-repl index 5d0d7de4..c406b009 100755 --- a/test/repl/test-repl +++ b/test/repl/test-repl @@ -26,6 +26,7 @@ actual=$MH_TEST_DIR/Mail/draft # check -help +start_test -help cat >$expected <"$actual" 2>&1 check "$expected" "$actual" # check -version +start_test -version case `repl -v` in repl\ --*) ;; * ) printf '%s: repl -v generated unexpected output\n' "$0" >&2 @@ -69,15 +71,18 @@ case `repl -v` in esac # check unknown switch +start_test 'unknown switch' run_test "repl -nonexistent" 'repl: -nonexistent unknown' # check with no switches +start_test 'with no switches' run_test "repl" 'repl: no cur message' printf 'Local-Mailbox: mymailbox@localhost\n' >> "$MH" # check -cc me +start_test '-cc me' cat >$expected < @@ -95,6 +100,7 @@ run_prog repl -cc me -editor true -nowhatnowproc 1 check $expected $actual # check -nocc me +start_test '-nocc me' cat >$expected < @@ -111,7 +117,8 @@ EOF run_prog repl -cc me -nocc me -editor true -nowhatnowproc 1 check $expected $actual -# check -cc me with Local- and Alternate-Mailbox addtions, Bug #36635: +# check -cc me with Local- and Alternate-Mailbox addtions, Bug #36635 +start_test '-cc me with Local- and Alternate-Mailbox addtions, Bug #36635' # -nocc me doesn't account for Alternate-Mailboxes. printf 'Alternate-Mailboxes: user@example.com\n' >> "$MH" @@ -132,7 +139,8 @@ run_prog repl -cc me -editor true -nowhatnowproc 1 check $expected $actual -# check -nocc me with Local- and Alternate-Mailbox addtions, Bug #36635: +# check -nocc me with Local- and Alternate-Mailbox addtions, Bug #36635 +start_test '-nocc me with Local- and Alternate-Mailbox addtions, Bug #36635' # -nocc me doesn't account for Alternate-Mailboxes. cat >$expected <`mhpath new` < To: before_auser@example.com, A. User , @@ -182,4 +191,51 @@ run_prog repl -cc to -editor true -nowhatnowproc 11 check $expected $actual +# check that Fcc: header isn't propagated +start_test "Fcc: header isn't propagated" +form="${MH_TEST_DIR}/$$.components" +cat > $form <<'EOF' +From: sender@example.com +%<{from}%(void(width))%(putaddr To: )%> +Fcc:%<{fcc} %{fcc}%> +Subject: %<{subject}Re: %(void{subject})%(trim)%(putstr)%> +-------- +EOF +cat > $expected < `mhpath new`< $expected <c_name = mh_xstrdup(""); } - /* set up the "fcc" pseudo-component */ - if (fcc) { - cptr = fmt_findcomp ("fcc"); - if (cptr) - cptr->c_text = mh_xstrdup(fcc); - } - if ((cp = getenv("USER"))) { - cptr = fmt_findcomp ("user"); - if (cptr) - cptr->c_text = mh_xstrdup(cp); - } if (!ccme) ismymbox (NULL); @@ -179,6 +168,24 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, finished: m_getfld_state_destroy (&gstate); + /* set up the "fcc" pseudo-component */ + cptr = fmt_findcomp ("fcc"); + if (cptr) { + mh_xfree(cptr->c_text); + if (fcc) + cptr->c_text = mh_xstrdup(fcc); + else + cptr->c_text = NULL; + } + cptr = fmt_findcomp ("user"); + if (cptr) { + mh_xfree(cptr->c_text); + if ((cp = getenv("USER"))) + cptr->c_text = mh_xstrdup(cp); + else + cptr = NULL; + } + /* * if there's a "Subject" component, strip any "Re:"s off it */ -- 2.56.0