From 91d19c2e09319d1e421cfb08fe5f298b79f39c33 Mon Sep 17 00:00:00 2001 From: Matt Zagrabelny Date: Fri, 27 Jan 2017 15:27:48 -0600 Subject: [PATCH 1/2] if any of the IP objects are not addresses, then use the 'block' view Don't just evaluate the first object of the array - this leads to issues where a container has static addresses at the top of the addressing block (first entry of the array) and the whole block is rendered as though they were hosts (addresses). Instead, default to 'address' and see if any of the objects are not addresses. If so, then set the type to 'block' and break the loop. --- htdocs/management/ipblock_list.mhtml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/management/ipblock_list.mhtml b/htdocs/management/ipblock_list.mhtml index 1a3c4b932..1959c0baa 100644 --- a/htdocs/management/ipblock_list.mhtml +++ b/htdocs/management/ipblock_list.mhtml @@ -37,10 +37,12 @@ if ( $type ){ $m->comp('error.mhtml', error => "Unknown type: $type"); } }else{ - if ( ($objects->[0])->is_address ){ # We're dealing with addresses - $type = "address"; - }else{ - $type = "block"; + $type = 'address'; + for my $object (@$objects) { + if (! $object->is_address) { + $type = 'block'; + last; + } } } From 8928213238e25e44c14706b61a77eb73c2dbd05f Mon Sep 17 00:00:00 2001 From: Matt Zagrabelny Date: Fri, 27 Jan 2017 15:33:29 -0600 Subject: [PATCH 2/2] fix regex binding order error Regex anchors bind tighter than the alternation character (|). Thus we need to put our alternation expression in a (non-capturing) parenthesis. --- htdocs/management/ipblock_list.mhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/management/ipblock_list.mhtml b/htdocs/management/ipblock_list.mhtml index 1959c0baa..bd6d62625 100644 --- a/htdocs/management/ipblock_list.mhtml +++ b/htdocs/management/ipblock_list.mhtml @@ -33,7 +33,7 @@ my $i; my (@headers, @rows); if ( $type ){ - unless ( $type =~ /^address|block$/ ){ + unless ( $type =~ /^(?:address|block)$/ ){ $m->comp('error.mhtml', error => "Unknown type: $type"); } }else{