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:19:21 +0200 |
| commit | 2a66d12e77821fbd4f2e4c3cb93eb9f84ca6f9ab (patch) | |
| tree | c505a57a41adb2750ed0428449b005a14ba59ff3 /django/core/validators.py | |
| parent | 79f15ab1ef964c0209c4484ccf62ba458fd582b3 (diff) | |
[1.7.x] Fixed #22579 -- Corrected validation for email to reject trailing slash
Backport of 424fe76349a2e34eafef13c2450a7a1f4d3115a6 from master.
Diffstat (limited to 'django/core/validators.py')
| -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) |
