From a5a3b4c3e770c68059720e81546c1006c67b5859 Mon Sep 17 00:00:00 2001 From: teastep Date: Thu, 26 Feb 2009 17:12:55 +0000 Subject: [PATCH] Make split_list1() a little more robust git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@9543 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall/Shorewall/Config.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Shorewall/Shorewall/Config.pm b/Shorewall/Shorewall/Config.pm index 15d575d71..75f11119a 100644 --- a/Shorewall/Shorewall/Config.pm +++ b/Shorewall/Shorewall/Config.pm @@ -1172,15 +1172,18 @@ sub split_list1( $$ ) { my $element = ''; for ( @list1 ) { - if ( /\(/ ) { - fatal_error "Invalid $type list ($list)" if $element; - if ( /\)/ ) { + my $count; + + 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 , $_; } else { $element = $_; } - } elsif ( /\)$/ ) { - fatal_error "Invalid $type list ($list)" unless $element; + } elsif ( ( $count = tr/)/)/ ) > 0 ) { + fatal_error "Invalid $type list ($list)" unless $element && $count == 1; push @list2, join ',', $element, $_; $element = ''; } elsif ( $element ) {