diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-01-14 23:08:50 +0100 |
|---|---|---|
| committer | nessita <124304+nessita@users.noreply.github.com> | 2025-01-15 13:46:06 -0300 |
| commit | b3c5830769d8a5dbf2f974da7116fe503c9454d9 (patch) | |
| tree | c8cad631c1f0307b3ee56d956a4192c9fde179b2 /django/utils | |
| parent | 1602666b79ab438930b74b576f2fa1b6bcf0377b (diff) | |
Fixed #36098 -- Fixed validate_ipv6_address()/validate_ipv46_address() crash for non-string values.
Regression in ca2be7724e1244a4cb723de40a070f873c6e94bf.
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/ipv6.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/django/utils/ipv6.py b/django/utils/ipv6.py index 1b79d52226..c77083e3cf 100644 --- a/django/utils/ipv6.py +++ b/django/utils/ipv6.py @@ -51,12 +51,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 |
