From: David Levine Date: Fri, 29 Jun 2012 01:59:23 +0000 (-0500) Subject: Fixed ismymbox() to look at Local-Mailbox as well as X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=b3c37ca5f7bd503f07787e1ac87c1af2ab37f5ba;p=mmh Fixed ismymbox() to look at Local-Mailbox as well as Alternate-Mailboxes. The problem was that when an alternate mailbox was added to the list, the node for the local mailbox information was lost. Added check to test-mymbox. Added test-repl, because this is where it was first noticed. Also enhanced output with MHWDEBUG set to show the entire list, not just each alternate mailbox as it is added to the list. [Bug #36635]. --- diff --git a/Makefile.am b/Makefile.am index b49fc53..37568c8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -67,7 +67,7 @@ TESTS = test/ali/test-ali \ test/post/test-post-group \ test/refile/test-refile \ test/repl/test-if-str test/repl/test-trailing-newline \ - test/repl/test-multicomp \ + test/repl/test-multicomp test/repl/test-repl \ test/scan/test-scan test/scan/test-scan-multibyte \ test/sequences/test-flist test/sequences/test-mark \ test/whatnow/test-attach-detach test/whatnow/test-cd \ diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index fc026fb..6c9fe0e 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -193,6 +193,8 @@ getm (char *str, char *dfhost, int dftype, int wanthost, char *eresult) goto got_host; } + /* For alternate mailboxes, m_type gets overwritten in ismymbox () + to support wild-card matching. */ if (wanthost == AD_NHST) mp->m_type = !mh_strcasecmp (LocalName (0), mp->m_host) ? LOCALHOST : NETHOST; @@ -356,7 +358,7 @@ ismymbox (struct mailname *np) if ((am = context_find ("alternate-mailboxes")) == NULL) am = getusername(); else { - mp = &mq; + mp = mq.m_next ? mq.m_next : &mq; oops = 0; while ((cp = getname (am))) { if ((mp->m_next = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) { @@ -383,16 +385,23 @@ ismymbox (struct mailname *np) *cp = '\0'; } } - if ((cp = getenv ("MHWDEBUG")) && *cp) - fprintf (stderr, "mbox=\"%s\" host=\"%s\" %s\n", - mp->m_mbox, mp->m_host, - snprintb (buffer, sizeof(buffer), (unsigned) mp->m_type, WBITS)); } } if (oops) advise (NULL, "please fix the %s: entry in your %s file", "alternate-mailboxes", mh_profile); } + + if ((cp = getenv ("MHWDEBUG")) && *cp) { + for (mp = &mq; mp; mp = mp->m_next) { + fprintf (stderr, "Local- or Alternate-Mailbox: text=\"%s\" " + "mbox=\"%s\" host=\"%s\" %s\n", + mp->m_text ? mp->m_text : "", mp->m_mbox, + mp->m_host ? mp->m_host : "", + snprintb (buffer, sizeof(buffer), (unsigned) mp->m_type, + WBITS)); + } + } } if (np == NULL) /* XXX */ diff --git a/test/format/test-mymbox b/test/format/test-mymbox index 786d943..2cc1bb6 100755 --- a/test/format/test-mymbox +++ b/test/format/test-mymbox @@ -41,4 +41,11 @@ run_test "echo `${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \ output=`${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"` run_test "echo $output" 0 "Local-mailbox overriding user@host test" +# Add an Alternate-Mailbox. This caused ismymbox() to lose the +# Local-Mailbox, Bug #36635: -nocc me doesn't account for +# Alternate-Mailboxes. +printf "Alternate-Mailboxes: user@example.com\n" >> $MH +run_test "echo `${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \ + 1 "Local-Mailbox with Alternate-Mailbox test" + exit $failed diff --git a/test/repl/test-repl b/test/repl/test-repl new file mode 100755 index 0000000..d9c39a1 --- /dev/null +++ b/test/repl/test-repl @@ -0,0 +1,143 @@ +#!/bin/sh +###################################################### +# +# Test repl +# +###################################################### + +# This is not a comprehensive test of repl, but some day it will be :-) +# Please add to it. + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +expected=$MH_TEST_DIR/$$.expected +actual=$MH_TEST_DIR/Mail/draft + + +# check -help +cat >$expected <$actual 2>&1 +check $expected $actual + +# check -version +case `repl -v` in + repl\ --*) ;; + * ) printf "$0: repl -v generated unexpected output\n" >&2 + failed=`expr ${failed:-0} + 1`;; +esac + +# check unknown switch +run_test "repl -nonexistent" 'repl: -nonexistent unknown' + +# check with no switches +run_test "repl" 'repl: no cur message' + + +printf "Local-Mailbox: mymailbox@localhost%s\n" >> $MH + +# check -cc me +cat >$expected < +cc: mymailbox@localhost +Fcc: +outbox +Subject: Re: Testing message 1 +Comments: In-reply-to Test1 + message dated "Fri, 29 Sep 2006 00:00:00." +-------- +EOF + +repl -cc me -editor true -nowhatnowproc 1 +check $expected $actual + +# check -nocc me +cat >$expected < +cc: +Fcc: +outbox +Subject: Re: Testing message 1 +Comments: In-reply-to Test1 + message dated "Fri, 29 Sep 2006 00:00:00." +-------- +EOF + +repl -cc me -nocc me -editor true -nowhatnowproc 1 +check $expected $actual + +# check -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 + +cat >$expected < +cc: mymailbox@localhost +Fcc: +outbox +Subject: Re: Testing message 1 +Comments: In-reply-to Test1 + message dated "Fri, 29 Sep 2006 00:00:00." +-------- +EOF + +repl -cc me -editor true -nowhatnowproc 1 +check $expected $actual + + +# check -nocc me with Local- and Alternate-Mailbox addtions, Bug #36635: +# -nocc me doesn't account for Alternate-Mailboxes. +cat >$expected < +cc: +Fcc: +outbox +Subject: Re: Testing message 1 +Comments: In-reply-to Test1 + message dated "Fri, 29 Sep 2006 00:00:00." +-------- +EOF + +repl -cc me -nocc me -editor true -nowhatnowproc 1 +check $expected $actual + + +exit ${failed:-0}