mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-18 23:44:37 +01:00
fix(utilities): Add atomic group in expandable field regex pattern
Replace non-capturing group with atomic group in expansion bracket regex to prevent excessive backtracking. Add missing 'object' key to bulk view context for template compatibility.
This commit is contained in:
@@ -258,6 +258,7 @@ class BulkCreateView(GetReturnURLMixin, BaseMultiObjectView):
|
||||
def _get_context(self, request, form, model_form):
|
||||
model = self.queryset.model
|
||||
return {
|
||||
'object': None,
|
||||
'obj_type': model._meta.verbose_name,
|
||||
'obj_type_plural': model._meta.verbose_name_plural,
|
||||
'form': form,
|
||||
|
||||
@@ -59,7 +59,7 @@ class ExpandableIPNetworkField(forms.CharField):
|
||||
return [value]
|
||||
|
||||
# Replace expansion brackets with a neutral value to get a parseable IP/CIDR
|
||||
stripped = re.sub(r'\[[^\]]+\]', '0', value)
|
||||
stripped = re.sub(r'(?>\[[^\]]+\])', '0', value)
|
||||
try:
|
||||
family = netaddr.IPNetwork(stripped).version
|
||||
except (netaddr.AddrFormatError, ValueError):
|
||||
|
||||
Reference in New Issue
Block a user