diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-01-14 23:08:50 +0100 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2025-01-15 13:54:57 -0300 |
| commit | 043dfadbcebc752d5ab2e9ff08c7e48044d20dc2 (patch) | |
| tree | 5ddece46e01540ffba77caa09bc36f760c205792 /django | |
| parent | 8769b44fdabc960dc23d1222430470809fd751b1 (diff) | |
[4.2.x] Fixed #36098 -- Fixed validate_ipv6_address()/validate_ipv46_address() crash for non-string values.
Regression in ca2be7724e1244a4cb723de40a070f873c6e94bf.
Backport of b3c5830769d8a5dbf2f974da7116fe503c9454d9 from main.
Diffstat (limited to 'django')
| -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 de41a97f72..487fa7b1e1 100644 --- a/django/utils/ipv6.py +++ b/django/utils/ipv6.py @@ -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 |
