Fixes #4338: Catch AddrFormatError exception when filtering aggregates/prefixes by an invalid prefix

This commit is contained in:
Jeremy Stretch 2020-03-10 11:58:34 -04:00
parent 2571f22ae5
commit 1eddac4066
2 changed files with 3 additions and 2 deletions

View File

@ -16,6 +16,7 @@
* [#4326](https://github.com/netbox-community/netbox/issues/4326) - Exclude Python modules without Script classes from scripts list
* [#4337](https://github.com/netbox-community/netbox/issues/4337) - Allow bulk editing/deletion of all device components matching a query
* [#4338](https://github.com/netbox-community/netbox/issues/4338) - Catch `AddrFormatError` exception when filtering aggregates/prefixes by an invalid prefix
---

View File

@ -111,7 +111,7 @@ class AggregateFilterSet(BaseFilterSet, CustomFieldFilterSet, CreatedUpdatedFilt
try:
query = str(netaddr.IPNetwork(value).cidr)
return queryset.filter(prefix=query)
except ValidationError:
except (AddrFormatError, ValueError):
return queryset.none()
@ -233,7 +233,7 @@ class PrefixFilterSet(BaseFilterSet, TenancyFilterSet, CustomFieldFilterSet, Cre
try:
query = str(netaddr.IPNetwork(value).cidr)
return queryset.filter(prefix=query)
except ValidationError:
except (AddrFormatError, ValueError):
return queryset.none()
def search_within(self, queryset, name, value):