------------------------------------------------------------
revno: 1060
committer: Mark Sapiro <[EMAIL PROTECTED]>
branch nick: 2.1
timestamp: Sat 2008-03-15 22:09:31 -0700
message:
  Gui/GuiBase.py         - Don't allow self references in *_these_nonmembers
                           or regular_(in|ex)clude_lists.
  
  Handlers/CalcRecips.py - Log and skip any self reference lists in
                           regular_(in|ex)clude_lists.
                           Compare To: and Cc: addresses and
                           regular_(in|ex)clude_lists case insensitively.
  
  Handlers/Moderate.py   - Log and skip any self reference lists in
                           *_these_nonmembers.
modified:
  Mailman/Gui/GUIBase.py
  Mailman/Handlers/CalcRecips.py
  Mailman/Handlers/Moderate.py

=== modified file 'Mailman/Gui/GUIBase.py'
--- a/Mailman/Gui/GUIBase.py    2007-11-18 20:01:26 +0000
+++ b/Mailman/Gui/GUIBase.py    2008-03-16 05:09:31 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2007 by the Free Software Foundation, Inc.
+# Copyright (C) 2002-2008 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -78,12 +78,20 @@
                             re.compile(addr)
                         except re.error:
                             raise ValueError
-                    elif wtype == mm_cfg.EmailListEx and addr.startswith('@'):
+                    elif (wtype == mm_cfg.EmailListEx and addr.startswith('@')
+                            and property.endswith('_these_nonmembers')):
                         # XXX Needs to be reviewed for [EMAIL PROTECTED] names.
-                        # check for existence of list?
-                        pass
+                        # don't reference your own list
+                        if addr[1:] == mlist.internal_name():
+                            raise ValueError
+                        # check for existence of list?  For now allow
+                        # reference to list before creating it.
                     else:
                         raise
+                if property in ('regular_exclude_lists',
+                                'regular_include_lists'):
+                    if addr.lower() == mlist.GetListEmail().lower():
+                        raise Errors.EmailAddressError
                 addrs.append(addr)
             return addrs
         # This is a host name, i.e. verbatim

=== modified file 'Mailman/Handlers/CalcRecips.py'
--- a/Mailman/Handlers/CalcRecips.py    2007-11-25 07:08:04 +0000
+++ b/Mailman/Handlers/CalcRecips.py    2008-03-16 05:09:31 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2008 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -159,11 +159,16 @@
     recips = set(recips)
     destinations = email.Utils.getaddresses(msg.get_all('to', []) +
                                             msg.get_all('cc', []))
-    destinations = [y for x,y in destinations]
+    destinations = [y.lower() for x,y in destinations]
     for listname in mlist.regular_exclude_lists:
+        listname = listname.lower()
         if listname not in destinations:
             continue
         listlhs, hostname = listname.split('@')
+        if listlhs == mlist.internal_name():
+            syslog('error', 'Exclude list %s is a self reference.',
+                    listname)
+            continue
         try:
             slist = MailList(listlhs, lock=False)
         except MMUnknownListError:
@@ -190,11 +195,16 @@
     recips = set(recips)
     destinations = email.Utils.getaddresses(msg.get_all('to', []) +
                                             msg.get_all('cc', []))
-    destinations = [y for x,y in destinations]
+    destinations = [y.lower() for x,y in destinations]
     for listname in mlist.regular_include_lists:
+        listname = listname.lower()
         if listname in destinations:
             continue
         listlhs, hostname = listname.split('@')
+        if listlhs == mlist.internal_name():
+            syslog('error', 'Include list %s is a self reference.',
+                    listname)
+            continue
         try:
             slist = MailList(listlhs, lock=False)
         except MMUnknownListError:

=== modified file 'Mailman/Handlers/Moderate.py'
--- a/Mailman/Handlers/Moderate.py      2008-02-20 04:26:57 +0000
+++ b/Mailman/Handlers/Moderate.py      2008-03-16 05:09:31 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2008 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -89,15 +89,16 @@
     else:
         sender = msg.get_sender()
     # From here on out, we're dealing with non-members.
-    if matches_p(sender, mlist.accept_these_nonmembers):
+    listname = mlist.internal_name()
+    if matches_p(sender, mlist.accept_these_nonmembers, listname):
         return
-    if matches_p(sender, mlist.hold_these_nonmembers):
+    if matches_p(sender, mlist.hold_these_nonmembers, listname):
         Hold.hold_for_approval(mlist, msg, msgdata, Hold.NonMemberPost)
         # No return
-    if matches_p(sender, mlist.reject_these_nonmembers):
+    if matches_p(sender, mlist.reject_these_nonmembers, listname):
         do_reject(mlist)
         # No return
-    if matches_p(sender, mlist.discard_these_nonmembers):
+    if matches_p(sender, mlist.discard_these_nonmembers, listname):
         do_discard(mlist, msg)
         # No return
     # Okay, so the sender wasn't specified explicitly by any of the non-member
@@ -116,7 +117,7 @@
 
 
 
-def matches_p(sender, nonmembers):
+def matches_p(sender, nonmembers, listname):
     # First strip out all the regular expressions and listnames
     plainaddrs = [addr for addr in nonmembers if not (addr.startswith('^')
                                                  or addr.startswith('@'))]
@@ -135,12 +136,19 @@
         elif are.startswith('@'):
             # XXX Needs to be reviewed for [EMAIL PROTECTED] names.
             try:
-                mother = MailList(are[1:], lock=0)
-                if mother.isMember(sender):
-                    return 1
+                if are[1:] == listname:
+                    # don't reference your own list
+                    syslog('error',
+                        '*_these_nonmembers in %s references own list',
+                        listname)
+                else:
+                    mother = MailList(are[1:], lock=0)
+                    if mother.isMember(sender):
+                        return 1
             except Errors.MMUnknownListError:
-                syslog('error', 'filter references non-existent list %s',
-                        are[1:])
+                syslog('error',
+                  '*_these_nonmembers in %s references non-existent list %s',
+                  listname, are[1:])
     return 0
 
 



--
Stable, maintained release series
https://code.launchpad.net/~mailman-coders/mailman/2.1

You are receiving this branch notification because you are subscribed to it.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to