Ticket #3989: email_re.diff

File email_re.diff, 1.3 KB (added by Vinay Sajip <vinay_sajip@…>, 17 years ago)

Patch to email RE to allow matching "mailbox" production

  • django/core/validators.py

     
    2121ansi_date_re = re.compile('^%s$' % _datere)
    2222ansi_time_re = re.compile('^%s$' % _timere)
    2323ansi_datetime_re = re.compile('^%s %s$' % (_datere, _timere))
    24 email_re = re.compile(
    25     r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"  # dot-atom
    26     r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
    27     r')@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}$', re.IGNORECASE)  # domain
     24
     25DOT_ATOM = r"[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(?:\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"
     26QUOTED_STRING = r'"(?:[\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"'
     27DOMAIN = r'(?:[A-Z0-9-]+\.)+[A-Z]{2,6}'
     28ADDR_SPEC = "((?:" + DOT_ATOM + ")|(?:" + QUOTED_STRING + "))@(" + DOMAIN + ")"
     29DISPLAY_NAME = r'(?:\w[\w ]*)'
     30
     31email_re = re.compile("^(?:" + ADDR_SPEC + ")|" + DISPLAY_NAME + "<" + ADDR_SPEC + ">$", re.IGNORECASE)
     32
    2833integer_re = re.compile(r'^-?\d+$')
    2934ip4_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$')
    3035phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
Back to Top