Edgewall Software

Ticket #7203: ign-dom-default-dom.diff

File ign-dom-default-dom.diff, 2.3 KB (added by Stephen Compall <stephen.compall@…>, 8 months ago)

test and fix

  • trac/notification.py

    === modified file 'trac/notification.py'
     
    163163    from_email = 'trac+tickets@localhost' 
    164164    subject = '' 
    165165    template_name = None 
    166     nodomaddr_re = re.compile(r'[\w\d_\.\-]+') 
     166    nodomaddr_re = re.compile(r'[\w\d_\.\-]+$') 
    167167    addrsep_re = re.compile(r'[;\s,]+') 
    168168 
    169169    def __init__(self, env): 
     
    286286                else: 
    287287                    self.env.log.info("Email address w/o domain: %s" % address) 
    288288                    return None 
     289            else: 
     290                self.env.log.info("Ignored email address: %s" % address) 
     291                return None 
    289292 
    290293        mo = self.shortaddr_re.search(address) 
    291294        if mo: 
  • trac/ticket/tests/notification.py

    === modified file 'trac/ticket/tests/notification.py'
     
    268268            self.env.config.set('notification', 'always_notify_reporter', 
    269269                                'false') 
    270270            self.env.config.set('notification', 'smtp_always_cc', '') 
     271            self.env.config.set('notification', 'ignore_domains', 
     272                                'ignored.example.com') 
    271273            ticket = Ticket(self.env) 
    272             ticket['cc'] = 'joenodom, joewithdom@example.com' 
     274            ticket['cc'] = 'joenodom, joewithdom@example.com, ' \ 
     275                'otherjoe@ignored.example.com' 
    273276            ticket['summary'] = 'This is a summary' 
    274277            ticket.insert() 
    275278            # Be sure that at least one email address is valid, so that we  
     
    288291            cclist = [addr.strip() for addr in headers['Cc'].split(',')] 
    289292            self.failIf('joewithdom@example.com' not in cclist) 
    290293            self.failIf('joe.bar@example.net' not in cclist) 
     294            self.failIf(headers['Cc'].find('ignored') >= 0) 
    291295            if not enabled: 
    292296                self.failIf(len(cclist) != 2) 
    293297                self.failIf('joenodom' in cclist) 
     
    347351        # 'To' list should have been resolved to the actual email address 
    348352        self.failIf('kerb@example.net' not in tolist) 
    349353        self.failIf(len(tolist) != 1) 
    350          
     354 
    351355    def test_admit_domains(self): 
    352356        """SMTP domain inclusion""" 
    353357        self.env.config.set('notification', 'admit_domains',