diff options
| author | kimbo <kimballleavitt@gmail.com> | 2020-02-26 11:09:22 -0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-02-28 11:08:06 +0100 |
| commit | 7c6b66383da5f9a67142334cd2ed2d769739e8f1 (patch) | |
| tree | 38823185bc6130ea6f8906115123c7c8479cbb46 | |
| parent | 984531f96eb901f2dca732087171bfe8ced986c3 (diff) | |
Fixed #31311 -- Removed unneeded escapes in validator regexes.
Special characters lose their special meaning inside sets of characters.
"-" lose its special meaning if it's placed as the first or last
character.
| -rw-r--r-- | django/core/validators.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index dc0519bb6a..effa5140ce 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -65,7 +65,7 @@ class URLValidator(RegexValidator): # IP patterns ipv4_re = r'(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}' - ipv6_re = r'\[[0-9a-f:\.]+\]' # (simple regex, validated later) + ipv6_re = r'\[[0-9a-f:.]+\]' # (simple regex, validated later) # Host patterns hostname_re = r'[a-z' + ul + r'0-9](?:[a-z' + ul + r'0-9-]{0,61}[a-z' + ul + r'0-9])?' @@ -82,7 +82,7 @@ class URLValidator(RegexValidator): host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)' regex = _lazy_re_compile( - r'^(?:[a-z0-9\.\-\+]*)://' # scheme is validated separately + r'^(?:[a-z0-9.+-]*)://' # scheme is validated separately r'(?:[^\s:@/]+(?::[^\s:@/]*)?@)?' # user:pass authentication r'(?:' + ipv4_re + '|' + ipv6_re + '|' + host_re + ')' r'(?::\d{2,5})?' # port @@ -163,7 +163,7 @@ class EmailValidator: re.IGNORECASE) literal_regex = _lazy_re_compile( # literal form, ipv4 or ipv6 address (SMTP 4.1.3) - r'\[([A-f0-9:\.]+)\]\Z', + r'\[([A-f0-9:.]+)\]\Z', re.IGNORECASE) domain_whitelist = ['localhost'] |
