Teach spost to handle address groups
authorPhilipp Takacs <philipp@bureaucracy.de>
Sun, 1 Nov 2015 21:35:29 +0000 (22:35 +0100)
committermarkus schnalke <meillo@marmaro.de>
Sun, 1 Nov 2015 21:35:29 +0000 (22:35 +0100)
Plus more tests for address groups.

test/tests/spost/test-group
uip/spost.c

index 13c3bf1..c65e58c 100644 (file)
@@ -14,10 +14,12 @@ cd - >/dev/null
 export MMHP="$profile"
 
 
 export MMHP="$profile"
 
 
+
 # Group Recipients
 
 cat >"$draft" <<!
 # Group Recipients
 
 cat >"$draft" <<!
-To: Undisclosed recipients: Alice <alice@example.org>, Gill <gill@example.org>;
+To: Undisclosed recipients: Alice <alice@example.org>,
+       Gill <gill@example.org>;
 Date: Sun, 25 Oct 2015 18:59:56 +0100
 Subject: Group Recipients
 ----------------
 Date: Sun, 25 Oct 2015 18:59:56 +0100
 Subject: Group Recipients
 ----------------
@@ -35,3 +37,146 @@ foo
 alice@example.org
 gill@example.org
 !
 alice@example.org
 gill@example.org
 !
+
+
+
+cat >"$draft" <<!
+To: charly@example.net
+Cc: friends: alice@example.org, Gill <gill@example.org>;
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Group in CC
+----------------
+foo
+!
+
+runandcheck 'spost -debug "$draft"' <<!
+To: charly@example.net
+Cc: friends: ;
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Group in CC
+From: Bob <bob@example.org>
+
+foo
+----EOM----
+alice@example.org
+gill@example.org
+charly@example.net
+!
+
+
+
+cat >"$draft" <<!
+To: charly@example.net
+Cc: friends: alice@example.org, Gill <gill@example.org>
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: No semicolon at the end of the group
+----------------
+foo
+!
+
+runandcheck 'spost -debug "$draft"' <<!
+To: charly@example.net
+Cc: friends: ;
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: No semicolon at the end of the group
+From: Bob <bob@example.org>
+
+foo
+----EOM----
+alice@example.org
+gill@example.org
+charly@example.net
+!
+
+
+
+cat >"$draft" <<!
+To: friends: Alice <alice@example.org>, Gill <gill@example.org>;,
+       charly@example.net
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Group plus address with comma
+----------------
+foo
+!
+
+runandcheck 'spost -debug "$draft"' <<!
+To: friends: ;, charly@example.net
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Group plus address with comma
+From: Bob <bob@example.org>
+
+foo
+----EOM----
+alice@example.org
+gill@example.org
+charly@example.net
+!
+
+
+
+cat >"$draft" <<!
+To: friends: Alice <alice@example.org>, Gill <gill@example.org>;
+       charly@example.net
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Group plus address, no comma
+----------------
+foo
+!
+
+runandcheck 'spost -debug "$draft"' <<!
+To: friends: ;, charly@example.net
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Group plus address, no comma
+From: Bob <bob@example.org>
+
+foo
+----EOM----
+alice@example.org
+gill@example.org
+charly@example.net
+!
+
+
+
+cat >"$draft" <<!
+To: abc:alice
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: One word with a colon inside
+----------------
+foo
+!
+
+runandcheck 'spost -debug "$draft"' <<!
+To: abc: ;
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: One word with a colon inside
+From: Bob <bob@example.org>
+
+foo
+----EOM----
+alice
+!
+
+
+
+cat >"$draft" <<!
+To: charly
+Dcc: friends: Alice <alice@example.org>, Gill <gill@example.org>;
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Group in Dcc
+----------------
+foo
+!
+
+runandcheck 'spost -debug "$draft"' <<!
+To: charly
+Date: Sun, 25 Oct 2015 18:59:56 +0100
+Subject: Group in Dcc
+From: Bob <bob@example.org>
+
+foo
+----EOM----
+alice@example.org
+gill@example.org
+charly
+!
index 780b5f4..7729e9b 100644 (file)
@@ -535,6 +535,7 @@ static void
 putadr(char *name, struct mailname *nl)
 {
        struct mailname *mp;
 putadr(char *name, struct mailname *nl)
 {
        struct mailname *mp;
+       char *cp;
        int linepos;
        int namelen;
 
        int linepos;
        int namelen;
 
@@ -547,7 +548,17 @@ putadr(char *name, struct mailname *nl)
                        fprintf(out, "\n%s: ", name);
                        linepos = namelen;
                }
                        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);
                mp = mp->m_next;
        }
        putc('\n', out);