Ticket #16310: 16310.email-regexp-fix.diff

File 16310.email-regexp-fix.diff, 1.4 KB (added by Julien Phalip, 13 years ago)

Fix + test

  • django/core/validators.py

    diff --git a/django/core/validators.py b/django/core/validators.py
    index 458f419..1cc9ab5 100644
    a b class EmailValidator(RegexValidator):  
    136136email_re = re.compile(
    137137    r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"  # dot-atom
    138138    r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
    139     r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$)'  # domain
     139    r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}$)'  # domain
    140140    r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE)  # literal form, ipv4 address (SMTP 4.1.3)
    141141validate_email = EmailValidator(email_re, _(u'Enter a valid e-mail address.'), 'invalid')
    142142
  • tests/modeltests/validators/tests.py

    diff --git a/tests/modeltests/validators/tests.py b/tests/modeltests/validators/tests.py
    index 9e254b9..bee29fa 100644
    a b TEST_DATA = (  
    3030    (validate_email, 'a @x.cz', ValidationError),
    3131    (validate_email, 'something@@somewhere.com', ValidationError),
    3232    (validate_email, 'email@127.0.0.1', ValidationError),
     33    (validate_email, 'email@here.com.', ValidationError),
    3334
    3435    (validate_slug, 'slug-ok', None),
    3536    (validate_slug, 'longer-slug-still-ok', None),
Back to Top