mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #32930 -- Fixed URLValidator when port numbers < 10.
This commit is contained in:
parent
b96cc7f85e
commit
65b880b726
@ -87,7 +87,7 @@ class URLValidator(RegexValidator):
|
||||
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
|
||||
r'(?::\d{1,5})?' # port
|
||||
r'(?:[/?#][^\s]*)?' # resource path
|
||||
r'\Z', re.IGNORECASE)
|
||||
message = _('Enter a valid URL.')
|
||||
@ -129,7 +129,7 @@ class URLValidator(RegexValidator):
|
||||
raise
|
||||
else:
|
||||
# Now verify IPv6 in the netloc part
|
||||
host_match = re.search(r'^\[(.+)\](?::\d{2,5})?$', urlsplit(value).netloc)
|
||||
host_match = re.search(r'^\[(.+)\](?::\d{1,5})?$', urlsplit(value).netloc)
|
||||
if host_match:
|
||||
potential_ip = host_match[1]
|
||||
try:
|
||||
|
@ -60,6 +60,7 @@ http://1.2.03.4
|
||||
http://1.2.3.04
|
||||
http://.www.foo.bar/
|
||||
http://.www.foo.bar./
|
||||
http://[::1:2::3]:8/
|
||||
http://[::1:2::3]:8080/
|
||||
http://[]
|
||||
http://[]:8080
|
||||
|
@ -2,6 +2,8 @@ http://www.djangoproject.com/
|
||||
HTTP://WWW.DJANGOPROJECT.COM/
|
||||
http://localhost/
|
||||
http://example.com/
|
||||
http://example.com:0
|
||||
http://example.com:0/
|
||||
http://example.com:65535
|
||||
http://example.com:65535/
|
||||
http://example.com./
|
||||
@ -37,6 +39,8 @@ http://userid:@example.com:8080
|
||||
http://userid:@example.com:8080/
|
||||
http://userid:password@example.com
|
||||
http://userid:password@example.com/
|
||||
http://userid:password@example.com:8
|
||||
http://userid:password@example.com:8/
|
||||
http://userid:password@example.com:8080
|
||||
http://userid:password@example.com:8080/
|
||||
http://userid:password@example.com:65535
|
||||
|
Loading…
Reference in New Issue
Block a user