Update of /cvsroot/ldapsh/ldapsh
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24500
Modified Files:
ldapsh
Log Message:
* Another attempt at filter escaping (now available without psh support).
Index: ldapsh
===================================================================
RCS file: /cvsroot/ldapsh/ldapsh/ldapsh,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** ldapsh 24 Feb 2004 05:19:12 -0000 1.49
--- ldapsh 24 Feb 2004 05:44:02 -0000 1.50
***************
*** 622,626 ****
BaseDN => $Globals->{CWD}{VALUE},
Scope => $Options->{r} ? 'sub' : 'one',
! Filter => $spec,
Attribs => []
);
--- 622,626 ----
BaseDN => $Globals->{CWD}{VALUE},
Scope => $Options->{r} ? 'sub' : 'one',
! Filter => _escape_filter( $spec ),
Attribs => []
);
***************
*** 783,791 ****
}
sub _escape {
#return Psh::OS::_escape(shift);
my $text = shift;
$text =~ s/(?<!\\)([ ])/\\$1/g;
- $text =~ s/(?<!\\)([*()])/\\\\$1/g;
return $text;
}
--- 783,799 ----
}
+ sub _escape_filter {
+ my $text = shift;
+ # escape special characters in LDAP filters (e.g. those that result
+ # from tab completion), unless it appears that the user constructed
+ # a complex filter by hand.
+ $text =~ s/(?<!\\)([*()\\])/\\$1/g unless $text =~ /^\(/;
+ return $text;
+ }
+
sub _escape {
#return Psh::OS::_escape(shift);
my $text = shift;
$text =~ s/(?<!\\)([ ])/\\$1/g;
return $text;
}
***************
*** 794,798 ****
#return Psh::Parser::remove_backslash(shift);
my $text = shift;
! $text =~ s/\\([ *()])/$1/g;
return $text;
}
--- 802,806 ----
#return Psh::Parser::remove_backslash(shift);
my $text = shift;
! $text =~ s/\\([ ])/$1/g;
return $text;
}
***************
*** 1672,1676 ****
BaseDN => $basedn,
Scope => $scope,
! Filter => $filter,
Attrs => \@attr
);
--- 1680,1684 ----
BaseDN => $basedn,
Scope => $scope,
! Filter => _escape_filter( $filter ),
Attrs => \@attr
);
|