Ticket #22579: 22579-1.diff

File 22579-1.diff, 2.3 KB (added by Claude Paroz, 11 years ago)
  • django/core/validators.py

    diff --git a/django/core/validators.py b/django/core/validators.py
    index cc71b72..8655266 100644
    a b class RegexValidator(object):  
    5858class URLValidator(RegexValidator):
    5959    regex = re.compile(
    6060        r'^(?:[a-z0-9\.\-]*)://'  # scheme is validated separately
    61         r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  # domain...
     61        r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}(?<!-)\.?)|'  # domain...
    6262        r'localhost|'  # localhost...
    6363        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|'  # ...or ipv4
    6464        r'\[?[A-F0-9]*:[A-F0-9:]+\]?)'  # ...or ipv6
    class EmailValidator(object):  
    114114        r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)',  # quoted-string
    115115        re.IGNORECASE)
    116116    domain_regex = re.compile(
    117         r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,})$',
     117        r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,}(?<!-))$',
    118118        re.IGNORECASE)
    119119    literal_regex = re.compile(
    120120        # literal form, ipv4 or ipv6 address (SMTP 4.1.3)
  • tests/validators/tests.py

    diff --git a/tests/validators/tests.py b/tests/validators/tests.py
    index 928c482..9330ab5 100644
    a b TEST_DATA = (  
    5858    (validate_email, 'email@[::ffff:127.0.0.256]', ValidationError),
    5959    (validate_email, 'example@invalid-.com', ValidationError),
    6060    (validate_email, 'example@-invalid.com', ValidationError),
     61    (validate_email, 'example@invalid.com-', ValidationError),
    6162    (validate_email, 'example@inv-.alid-.com', ValidationError),
    6263    (validate_email, 'example@inv-.-alid.com', ValidationError),
    6364    (validate_email, 'test@example.com\n\n<script src="x.js">', ValidationError),
    TEST_DATA = (  
    174175    (URLValidator(), 'http://.com', ValidationError),
    175176    (URLValidator(), 'http://invalid-.com', ValidationError),
    176177    (URLValidator(), 'http://-invalid.com', ValidationError),
     178    (URLValidator(), 'http://invalid.com-', ValidationError),
    177179    (URLValidator(), 'http://inv-.alid-.com', ValidationError),
    178180    (URLValidator(), 'http://inv-.-alid.com', ValidationError),
    179181    (URLValidator(), 'file://localhost/path', ValidationError),
Back to Top