diff --git a/django/core/validators.py b/django/core/validators.py index da59c0e924..1e599ec765 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -68,7 +68,7 @@ class RegexValidator(object): class URLValidator(RegexValidator): regex = re.compile( r'^(?:[a-z0-9\.\-]*)://' # scheme is validated separately - r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain... + r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}(?', ValidationError), @@ -174,6 +175,7 @@ TEST_DATA = ( (URLValidator(), 'http://.com', ValidationError), (URLValidator(), 'http://invalid-.com', ValidationError), (URLValidator(), 'http://-invalid.com', ValidationError), + (URLValidator(), 'http://invalid.com-', ValidationError), (URLValidator(), 'http://inv-.alid-.com', ValidationError), (URLValidator(), 'http://inv-.-alid.com', ValidationError), (URLValidator(), 'file://localhost/path', ValidationError),