On 10/15/2015 9:33 PM, Mark Sapiro wrote:
Mark Sapiro wrote:
On 10/15/2015 02:37 PM, Chris Nulk wrote:
to the following ( I have added ** at the beginning of the lines I added
to indicate the changes - in practice the ** would be spaces)

     def GetBannedPattern(self, email):
         """Returns matched entry in ban_list if email matches.
         Otherwise returns None.
         """
         ban = False
         for pattern in self.ban_list:
             if pattern.startswith('^'):
                 # This is a regular expression match
                 try:
                     if re.search(pattern, email, re.IGNORECASE):
                         ban = True
                         break
                 except re.error:
                     # BAW: we should probably remove this pattern
                     pass
**          elif pattern.startswith('@'):
**              listname = self.internal_name()  # is this correct?
**              try:
**                  mname = pattern[1:].lower().strip()
**                  if mname == listname:
**                      # don't reference your own list
**                      syslog('error',
**                          'Ban_list listfor %s references own list',
**                          listname)
**                  else:
**                      mother = MailList(mname, lock=0)
**                      if mother.isMember(email):
**                          ban = True
**                          break
**              except Errors.MMUnknownListError:
**                  syslog('error',
**                      'Ban_list for list %s references non-existent
list %s',
**                      listname, mname)
             else:
                 # Do the comparison case insensitively
                 if pattern.lower() == email.lower():
                     ban = True
                     break
         if ban:
             return pattern
         else:
             return None

Am I on the correct path?

Yes.

One more thing however. While the above code looks good for processing
@listname entries in ban_list, you won't be able to add them via the
list admin GUI unless you also modify Mailman/Gui/GUIBase.py. You need
to find the lines in that module that in 2.1.18-1 are

         elif (wtype == mm_cfg.EmailListEx and addr.startswith('@')
                 and property.endswith('_these_nonmembers')):

only indented more than above and change them to

         elif (wtype == mm_cfg.EmailListEx and addr.startswith('@')
                 and (property.endswith('_these_nonmembers') or
                      property == 'ban_list')):

If you don't make that change, you will still be able to add @listname
entries to a list's ban_list with withlist or other scripts, but the web
admin GUI will report them as bad email addresses.

Thank you for letting me know. I am going to try to make the changes soon. We try not to make changes on Fridays unless we really want to come in on Saturday to fix things.

Thanks,
Chris
------------------------------------------------------
Mailman-Users mailing list Mailman-Users@python.org
https://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to