Make split_list1() a little more robust

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@9543 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2009-02-26 17:12:55 +00:00
parent d1bbc2e820
commit a5a3b4c3e7

View File

@ -1172,15 +1172,18 @@ sub split_list1( $$ ) {
my $element = ''; my $element = '';
for ( @list1 ) { for ( @list1 ) {
if ( /\(/ ) { my $count;
fatal_error "Invalid $type list ($list)" if $element;
if ( /\)/ ) { if ( ( $count = tr/(/(/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" if $element || $count > 1;
if ( ( $count = tr/)/)/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" if $count > 1;
push @list2 , $_; push @list2 , $_;
} else { } else {
$element = $_; $element = $_;
} }
} elsif ( /\)$/ ) { } elsif ( ( $count = tr/)/)/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" unless $element; fatal_error "Invalid $type list ($list)" unless $element && $count == 1;
push @list2, join ',', $element, $_; push @list2, join ',', $element, $_;
$element = ''; $element = '';
} elsif ( $element ) { } elsif ( $element ) {