diff options
| author | Erik Romijn <eromijn@solidlinks.nl> | 2014-05-16 15:13:11 +0200 |
|---|---|---|
| committer | Erik Romijn <eromijn@solidlinks.nl> | 2014-05-16 15:13:11 +0200 |
| commit | 424fe76349a2e34eafef13c2450a7a1f4d3115a6 (patch) | |
| tree | e39616228e802229fd79e0eb1c8d41d2cbae2e9e /django | |
| parent | d64f192df188903ea5a1ab8dfd6679e5d52aaf9b (diff) | |
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.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/validators.py | 4 |
1 files changed, 2 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,}(?<!-)\.?)|' # domain... r'localhost|' # localhost... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|' # ...or ipv4 r'\[?[A-F0-9]*:[A-F0-9:]+\]?)' # ...or ipv6 @@ -124,7 +124,7 @@ class EmailValidator(object): r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)', # quoted-string re.IGNORECASE) domain_regex = re.compile( - r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,})$', + r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,}(?<!-))$', re.IGNORECASE) literal_regex = re.compile( # literal form, ipv4 or ipv6 address (SMTP 4.1.3) |
