Handle nested parens when pushing action parameters.

- Add an optional argument to split_list1 that causes parens to be retained.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2012-12-06 15:13:14 -08:00
parent 0a31d9ba41
commit 5f48e4e531
2 changed files with 7 additions and 7 deletions

View File

@ -1660,8 +1660,8 @@ sub split_list( $$;$ ) {
split /,/, $list;
}
sub split_list1( $$ ) {
my ($list, $type ) = @_;
sub split_list1( $$;$ ) {
my ($list, $type, $keepparens ) = @_;
fatal_error "Invalid $type list ($list)" if $list =~ /^,|,$|,,|!,|,!$/;
@ -1674,17 +1674,17 @@ sub split_list1( $$ ) {
if ( ( $count = tr/(/(/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" if $element || $count > 1;
s/\(//;
s/\(// unless $keepparens;
if ( ( $count = tr/)/)/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" if $count > 1;
s/\)//;
s/\)// unless $keepparens;
push @list2 , $_;
} else {
$element = $_;
}
} elsif ( ( $count = tr/)/)/ ) > 0 ) {
fatal_error "Invalid $type list ($list)" unless $element && $count == 1;
s/\)//;
s/\)// unless $keepparens;
push @list2, join ',', $element, $_;
$element = '';
} elsif ( $element ) {
@ -2510,7 +2510,7 @@ sub embedded_perl( $ ) {
# Push/pop action params
#
sub push_action_params( $$$$ ) {
my @params = ( undef , split /,/, $_[1] );
my @params = ( undef , split_list1( $_[1], 'parameter', 1 ) );
my %oldparams = %actparms;
%actparms = ();

View File

@ -1999,7 +1999,7 @@ sub process_rule1 ( $$$$$$$$$$$$$$$$$$ ) {
return $generated;
} elsif ( $actiontype & ( ACTION | INLINE ) ) {
split_list $param, 'Action parameter';
split_list1 $param, 'Action parameter';
} elsif ( $actiontype & NFQ ) {
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules', '' );
my $paramval = $param eq '' ? 0 : numeric_value( $param );