mirror of
https://github.com/django/django.git
synced 2025-11-29 06:51:10 +00:00
Fixed #31548 -- Fixed URLValidator crash on non-strings.
This commit is contained in:
parent
bda6ade7b7
commit
ccb1cfb64e
2 changed files with 5 additions and 1 deletions
|
|
@ -97,7 +97,9 @@ class URLValidator(RegexValidator):
|
|||
self.schemes = schemes
|
||||
|
||||
def __call__(self, value):
|
||||
# Check first if the scheme is valid
|
||||
if not isinstance(value, str):
|
||||
raise ValidationError(self.message, code=self.code)
|
||||
# Check if the scheme is valid.
|
||||
scheme = value.split('://')[0].lower()
|
||||
if scheme not in self.schemes:
|
||||
raise ValidationError(self.message, code=self.code)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue