From 66aa5fa11f02d91364b6954bda61cba1674770fe Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Sun, 1 Nov 2015 22:35:29 +0100 Subject: [PATCH] Teach spost to handle address groups Plus more tests for address groups. --- test/tests/spost/test-group | 147 ++++++++++++++++++++++++++++++++++++++++++- uip/spost.c | 13 +++- 2 files changed, 158 insertions(+), 2 deletions(-) diff --git a/test/tests/spost/test-group b/test/tests/spost/test-group index 13c3bf1..c65e58c 100644 --- a/test/tests/spost/test-group +++ b/test/tests/spost/test-group @@ -14,10 +14,12 @@ cd - >/dev/null export MMHP="$profile" + # Group Recipients cat >"$draft" <, Gill ; +To: Undisclosed recipients: Alice , + Gill ; Date: Sun, 25 Oct 2015 18:59:56 +0100 Subject: Group Recipients ---------------- @@ -35,3 +37,146 @@ foo alice@example.org gill@example.org ! + + + +cat >"$draft" <; +Date: Sun, 25 Oct 2015 18:59:56 +0100 +Subject: Group in CC +---------------- +foo +! + +runandcheck 'spost -debug "$draft"' < + +foo +----EOM---- +alice@example.org +gill@example.org +charly@example.net +! + + + +cat >"$draft" < +Date: Sun, 25 Oct 2015 18:59:56 +0100 +Subject: No semicolon at the end of the group +---------------- +foo +! + +runandcheck 'spost -debug "$draft"' < + +foo +----EOM---- +alice@example.org +gill@example.org +charly@example.net +! + + + +cat >"$draft" <, Gill ;, + charly@example.net +Date: Sun, 25 Oct 2015 18:59:56 +0100 +Subject: Group plus address with comma +---------------- +foo +! + +runandcheck 'spost -debug "$draft"' < + +foo +----EOM---- +alice@example.org +gill@example.org +charly@example.net +! + + + +cat >"$draft" <, Gill ; + charly@example.net +Date: Sun, 25 Oct 2015 18:59:56 +0100 +Subject: Group plus address, no comma +---------------- +foo +! + +runandcheck 'spost -debug "$draft"' < + +foo +----EOM---- +alice@example.org +gill@example.org +charly@example.net +! + + + +cat >"$draft" < + +foo +----EOM---- +alice +! + + + +cat >"$draft" <, Gill ; +Date: Sun, 25 Oct 2015 18:59:56 +0100 +Subject: Group in Dcc +---------------- +foo +! + +runandcheck 'spost -debug "$draft"' < + +foo +----EOM---- +alice@example.org +gill@example.org +charly +! diff --git a/uip/spost.c b/uip/spost.c index 780b5f4..7729e9b 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -535,6 +535,7 @@ static void putadr(char *name, struct mailname *nl) { struct mailname *mp; + char *cp; int linepos; int namelen; @@ -547,7 +548,17 @@ putadr(char *name, struct mailname *nl) fprintf(out, "\n%s: ", name); linepos = namelen; } - linepos = putone(mp->m_text, linepos, namelen); + if (mp->m_ingrp) { + if (mp->m_gname != NULL) { + cp = getcpy(mp->m_gname); + cp = add(";", cp); + linepos = putone(cp, linepos, namelen); + free(cp); + cp = NULL; + } + } else { + linepos = putone(mp->m_text, linepos, namelen); + } mp = mp->m_next; } putc('\n', out); -- 1.7.10.4