Changeset 572


Ignore:
Timestamp:
09/20/11 13:22:17 (10 years ago)
Author:
bas
Message:

adjusted email_header_acl we now loop over all to address to allow regexs like (*.sara.nl or basv@…), see #272

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r570 r572  
    257257            return False
    258258
    259     def email_header_acl(self, keyword, header_field, default):
     259    def email_header_acl(self, keyword, message_field, default):
    260260        """
    261261        This function wil check if the email address is allowed or denied
     
    273273
    274274        except KeyError, detail:
    275             self.logger.debug('%s not defined, all messages are allowed.' %(keyword))
     275            self.logger.debug('\t %s not defined, all messages are allowed.' %(keyword))
    276276
    277277            return default
    278278
    279279        mail_addresses = string.split(mail_addresses, ',')
     280        message_addresses = string.split(message_field, ',')
    280281
    281282        for entry in mail_addresses:
    282283            entry = entry.strip()
    283284            TO_RE = re.compile(entry, re.VERBOSE|re.IGNORECASE)
    284             result =  TO_RE.search(header_field)
    285             if result:
    286                 return True
     285
     286            for addr in message_addresses:
     287                addr = addr.strip()
     288
     289                if self.parameters.compare_function_list in [ 'matches', 'match']:
     290                    s = '\t%s matches %s' %(addr, entry)
     291                    result =  TO_RE.match(addr)
     292                else:
     293                    s = '\t%s contains %s' %(addr, entry)
     294                    result =  TO_RE.search(addr)
     295
     296                if result:
     297                    self.logger.debug(s)
     298                    return True
    287299
    288300        return False
Note: See TracChangeset for help on using the changeset viewer.