mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #21242 -- Allowed more IANA schemes in URLValidator
Thanks Sascha Peilicke for the report and initial patch, and Tim Graham for the review.
This commit is contained in:
@@ -18,6 +18,7 @@ from django.test.utils import str_prefix
|
||||
|
||||
|
||||
NOW = datetime.now()
|
||||
EXTENDED_SCHEMES = ['http', 'https', 'ftp', 'ftps', 'git', 'file']
|
||||
|
||||
TEST_DATA = (
|
||||
# (validator, value, expected),
|
||||
@@ -141,6 +142,7 @@ TEST_DATA = (
|
||||
(MinLengthValidator(10), '', ValidationError),
|
||||
|
||||
(URLValidator(), 'http://www.djangoproject.com/', None),
|
||||
(URLValidator(), 'HTTP://WWW.DJANGOPROJECT.COM/', None),
|
||||
(URLValidator(), 'http://localhost/', None),
|
||||
(URLValidator(), 'http://example.com/', None),
|
||||
(URLValidator(), 'http://www.example.com/', None),
|
||||
@@ -155,6 +157,8 @@ TEST_DATA = (
|
||||
(URLValidator(), 'https://example.com/', None),
|
||||
(URLValidator(), 'ftp://example.com/', None),
|
||||
(URLValidator(), 'ftps://example.com/', None),
|
||||
(URLValidator(EXTENDED_SCHEMES), 'file://localhost/path', None),
|
||||
(URLValidator(EXTENDED_SCHEMES), 'git://example.com/', None),
|
||||
|
||||
(URLValidator(), 'foo', ValidationError),
|
||||
(URLValidator(), 'http://', ValidationError),
|
||||
@@ -165,6 +169,9 @@ TEST_DATA = (
|
||||
(URLValidator(), 'http://-invalid.com', ValidationError),
|
||||
(URLValidator(), 'http://inv-.alid-.com', ValidationError),
|
||||
(URLValidator(), 'http://inv-.-alid.com', ValidationError),
|
||||
(URLValidator(), 'file://localhost/path', ValidationError),
|
||||
(URLValidator(), 'git://example.com/', ValidationError),
|
||||
(URLValidator(EXTENDED_SCHEMES), 'git://-invalid.com', ValidationError),
|
||||
|
||||
(BaseValidator(True), True, None),
|
||||
(BaseValidator(True), False, ValidationError),
|
||||
|
||||
Reference in New Issue
Block a user