Ticket #12027: email_re_patch.diff

File email_re_patch.diff, 1.0 KB (added by anonymous, 15 years ago)

Patch of regular expression for email address validation

  • django/forms/fields.py

     
    421421email_re = re.compile(
    422422    r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"  # dot-atom
    423423    r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
    424     r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE)  # domain
     424    r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}$', re.IGNORECASE)  # domain
    425425
    426426class EmailField(RegexField):
    427427    default_error_messages = {
     
    532532
    533533url_re = re.compile(
    534534    r'^https?://' # http:// or https://
    535     r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' #domain...
     535    r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}|' #domain...
    536536    r'localhost|' #localhost...
    537537    r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
    538538    r'(?::\d+)?' # optional port
Back to Top