From 424fe76349a2e34eafef13c2450a7a1f4d3115a6 Mon Sep 17 00:00:00 2001 From: Erik Romijn Date: Fri, 16 May 2014 15:13:11 +0200 Subject: [PATCH] Fixed #22579 -- Corrected validation for email to reject trailing slash Thanks to Claude Paroz for the report and patch and Tomasz Paczkowski for the review. --- django/core/validators.py | 4 ++-- tests/validators/tests.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) 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),