Просмотр исходного кода

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

Jeremy Stretch 6 лет назад
Родитель
Сommit
1eddac4066
2 измененных файлов с 3 добавлено и 2 удалено
  1. 1 0
      docs/release-notes/version-2.7.md
  2. 2 2
      netbox/ipam/filters.py

+ 1 - 0
docs/release-notes/version-2.7.md

@@ -16,6 +16,7 @@
 
 
 * [#4326](https://github.com/netbox-community/netbox/issues/4326) - Exclude Python modules without Script classes from scripts list
 * [#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
 * [#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
 
 
 ---
 ---
 
 

+ 2 - 2
netbox/ipam/filters.py

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