mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[5.0.x] Fixed #36098 -- Fixed validate_ipv6_address()/validate_ipv46_address() crash for non-string values.
Regression inca2be7724e. Backport ofb3c5830769from main.
This commit is contained in:
committed by
Natalia
parent
61fed511f1
commit
21dfd30d69
@@ -49,12 +49,14 @@ def clean_ipv6_address(
|
||||
return str(addr)
|
||||
|
||||
|
||||
def is_valid_ipv6_address(ip_str):
|
||||
def is_valid_ipv6_address(ip_addr):
|
||||
"""
|
||||
Return whether or not the `ip_str` string is a valid IPv6 address.
|
||||
Return whether the `ip_addr` object is a valid IPv6 address.
|
||||
"""
|
||||
if isinstance(ip_addr, ipaddress.IPv6Address):
|
||||
return True
|
||||
try:
|
||||
_ipv6_address_from_str(ip_str)
|
||||
except ValueError:
|
||||
_ipv6_address_from_str(ip_addr)
|
||||
except (TypeError, ValueError):
|
||||
return False
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user