make_filter: cope with filters that are already parenthesized
authorPeter Marschall <peter@adpm.de>
Sat, 05 Mar 2011 22:22:47 +0100
changeset 28 d42bd1b087a1
parent 27 7d170d1bc17b
child 29 bd95c3aea253
make_filter: cope with filters that are already parenthesized Treat filter elements correctly that may be more complex filters themselves; e.g. '(&(sn=Doe)(givenname=John))'
shelldap
--- a/shelldap	Sat Mar 05 22:13:27 2011 +0100
+++ b/shelldap	Sat Mar 05 22:22:47 2011 +0100
@@ -760,9 +760,9 @@
 	return unless scalar @$globs;
 
 	my $filter;
-	$filter = join '', map { "($_)" } @$globs;
-	$filter = '(|' . $filter . ')' if scalar @$globs > 1;
-	$filter = Net::LDAP::Filter->new( $filter );
+	$filter = join('', map { (/^\(.*\)$/o) ? $_ : "($_)" } @$globs);
+	$filter = '(|' . $filter . ')'  if (scalar(@$globs) > 1);
+	$filter = Net::LDAP::Filter->new($filter);
 
 	if ( $filter ) {
 		$self->debug('Filter parsed as: ' . $filter->as_string() . "\n");