Эх сурвалжийг харах

fixed theoretical bug if multiple mailgroups in To field... need to add a test for it

Pi 1 жил өмнө
parent
commit
d4662c8179

+ 3 - 2
filters/cropswap-members@shandan.one

@@ -1,4 +1,5 @@
-if (!$CONTINUE)
+MEMBERGROUPREGEX=escape($MEMBERGROUP)
+foreach (tolower $ADDR) =~ /^$MEMBERGROUPREGEX$/
 {
    foreach /^(To|Cc):\s+(.*)\s+\<$MEMBERGROUPREGEX\>$/
    {
@@ -10,7 +11,7 @@ if (!$CONTINUE)
    MAILGROUPALIAS="Crop Swap Members"
    SUBJECT="Crop Swap Member"
 }
-elsif ($CONTINUE)
+if ($FORWARD)
 {
    gdbmopen($MLIST, "R")
    ALIAS=gdbmfetch(tolower($FROM))

+ 3 - 2
filters/cropswap@shandan.one

@@ -1,4 +1,5 @@
-if (!$CONTINUE)
+ORGANIZERGROUPREGEX=escape($ORGANIZERGROUP)
+foreach (tolower $ADDR) =~ /^$ORGANIZERGROUPREGEX$/
 {
    foreach /^(To|Cc):\s+(.*)\s+\<$ORGANIZERGROUPREGEX\>$/
    {
@@ -9,7 +10,7 @@ if (!$CONTINUE)
    MAILGROUP=$ORGANIZERGROUP
    MAILGROUPALIAS="Crop Swap Notices"
 }
-elsif ($CONTINUE)
+if ($FORWARD)
 {
    NOFORWARD=$FROM
    SUBJECT="Crop Swap Query"

+ 4 - 2
filters/postmaster@localhost

@@ -1,5 +1,7 @@
 SIGNUPRESP="/opt/cropswap/signup.eml"
-if (!$CONTINUE)
+POSTMASTERREGEX=escape($POSTMASTER)
+ANYGROUPREGEX="$MEMBERGROUPREGEX|$ORGANIZERGROUPREGEX"
+foreach (tolower $ADDR) =~ /^$POSTMASTERREGEX$/
 {
    if (/^X\-GROUP:\s*($ANYGROUPREGEX)\s*$/)
    {
@@ -22,7 +24,7 @@ if (!$CONTINUE)
       CONTINUE=1
    }
 }
-elsif ($CONTINUE)
+if ($FORWARD)
 {
    if (/^X-MEMBER-ALIAS:\s*(.+)\s*$/)
    {

+ 11 - 17
maildroprc

@@ -19,21 +19,15 @@ if ($TEST)
    import MAILDROPDIR
 }
 POSTMASTER="postmaster@localhost"
-POSTMASTERREGEX=escape($POSTMASTER)
 
 # bi-directional group
 # From subscribed member -> other subscribed members
 MEMBERGROUP="cropswap-members@shandan.one"
-MEMBERGROUPREGEX=escape($MEMBERGROUP)
 
 # uni-directional group
 # From anyone -> organizers
 # From organizers -> subscribed members
 ORGANIZERGROUP="cropswap@shandan.one"
-ORGANIZERGROUPREGEX=escape($ORGANIZERGROUP)
-
-ANYGROUPREGEX="$MEMBERGROUPREGEX|$ORGANIZERGROUPREGEX"
-HANDLEDREGEX="$POSTMASTERREGEX|$ANYGROUPREGEX"
 
 UNHANDLED=5
 BADREQUEST=4
@@ -44,17 +38,9 @@ FATAL=1
 foreach /^(To|Cc):.*/
 {
    ADDR=getaddr($MATCH)
-   foreach (tolower $ADDR) =~ /^$HANDLEDREGEX$/
-   {
-      include "$FILTERDIR/$MATCH"
-   }
-}
-
-if (!$CONTINUE)
-{
-   cc "|$DEBUGMAIL no-continue"
-   EXITCODE=$UNHANDLED
-   exit
+   include "$FILTERDIR/$MEMBERGROUP"
+   include "$FILTERDIR/$ORGANIZERGROUP"
+   include "$FILTERDIR/$POSTMASTER"
 }
 
 if ($TOMEMBER && $TOORGANIZER)
@@ -71,6 +57,13 @@ if ($MAILGROUP eq "")
    exit
 }
 
+if (!$CONTINUE)
+{
+   cc "|$DEBUGMAIL no-continue"
+   EXITCODE=$UNHANDLED
+   exit
+}
+
 LISTDIR="$MAILDROPDIR/$MAILGROUP"
 MLIST="$LISTDIR/mlist"
 SLIST="$LISTDIR/slist"
@@ -79,6 +72,7 @@ gdbmopen($MLIST, "R")
 TO=gdbmfetch($TOALIAS)
 gdbmclose
 
+FORWARD=1
 if ($TOPOSTMASTER)
 {
    include "$FILTERDIR/$POSTMASTER"