Edgewall Software

Ticket #6609: EMAIL_LOOKALIKE_PATTERN-r6658.diff

File EMAIL_LOOKALIKE_PATTERN-r6658.diff, 2.0 KB (added by cboos, 4 years ago)

Put all the regexps together, shake, extract the best mix.

  • trac/wiki/parser.py

     
    2121import re 
    2222 
    2323from trac.core import * 
     24from trac.notification import EMAIL_LOOKALIKE_PATTERN 
    2425 
    2526class WikiParser(Component): 
    2627    """wiki subsystem dedicated to the Wiki text parsing.""" 
     
    7374 
    7475    _post_rules = [ 
    7576        # e-mails 
    76         r"(?P<email>\w[\w.]+@\w[\w.]+\w)", 
     77        r"(?P<email>%s)" % EMAIL_LOOKALIKE_PATTERN, 
    7778        # > ... 
    7879        r"(?P<citation>^(?P<cdepth>>(?: *>)*))", 
    7980        # &, < and > to &amp;, &lt; and &gt; 
  • trac/notification.py

     
    2424from trac.core import * 
    2525from trac.util.text import CRLF 
    2626from trac.util.translation import _ 
    27 from trac.web.chrome import Chrome 
    2827 
    2928MAXHEADERLEN = 76 
     29EMAIL_LOOKALIKE_PATTERN = (r"[a-zA-Z0-9.'=+-]+" '@' 
     30                            '(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}') 
    3031 
    31  
    3232class NotificationSystem(Component): 
    3333 
    3434    smtp_enabled = BoolOption('notification', 'smtp_enabled', 'false', 
     
    117117        self.config = env.config 
    118118        self.db = env.get_db_cnx() 
    119119 
     120        from trac.web.chrome import Chrome 
    120121        self.template = Chrome(self.env).load_template(self.template_name, 
    121122                                                       method='text') 
    122123        # FIXME: actually, we would need a Context with a different 
     
    166167    addrsep_re = re.compile(r'[;\s,]+') 
    167168 
    168169    def __init__(self, env): 
     170        global EMAIL_LOOKALIKE_PATTERN 
    169171        Notify.__init__(self, env) 
    170172 
    171         addrfmt = r'[\w\d_\.\-\+=]+\@(?:(?:[\w\d\-])+\.)+(?:[\w\d]{2,4})' 
     173        addrfmt = EMAIL_LOOKALIKE_PATTERN 
    172174        admit_domains = self.env.config.get('notification', 'admit_domains') 
    173175        if admit_domains: 
    174176            pos = addrfmt.find('@')