Update of /cvsroot/perl-ldap/ldap/lib/Net/LDAP
In directory usw-pr-cvs1:/tmp/cvs-serv31983/lib/Net/LDAP
Modified Files:
Filter.pm
Log Message:
Fix filters to be RFC compliant
Index: Filter.pm
===================================================================
RCS file: /cvsroot/perl-ldap/ldap/lib/Net/LDAP/Filter.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Filter.pm 2001/05/18 21:06:47 1.5
+++ Filter.pm 2002/01/09 17:19:47 1.6
@@ -7,7 +7,7 @@
use strict;
use vars qw($VERSION);
-$VERSION = "0.12";
+$VERSION = "0.13";
# filter = "(" filtercomp ")"
# filtercomp = and / or / not / item
@@ -87,10 +87,8 @@
/soxeg;
$_[0];
}
-
-my %ch = split(/\s+/, '( \\( ) \\) \\ \\\\ * \\*');
-sub _escape { (my $t = $_[0]) =~ s/([\\\(\)\*\0-\37])/$ch{$1}||sprintf("\\%02x",ord($1))/sge; $t }
+sub _escape { (my $t = $_[0]) =~ s/([\\\(\)\*\0-\37])/sprintf("\\%02x",ord($1))/sge; $t }
sub _encode {
my($attr,$op,$val) = @_;
@@ -109,9 +107,9 @@
return ( {
extensibleMatch => {
matchingRule => $rule,
- type => $type,
+ type => length($type) ? $type : undef,
matchValue => _unescape($val),
- dnAttributes => $dn ? 1 : 0
+ dnAttributes => $dn ? 1 : undef
}
});
}
@@ -119,14 +117,14 @@
# If the op is = and contains one or more * not
# preceeded by \ then do partial matches
- if ($op eq '=' && $val =~ /^(\\.|[^\\*]+)*\*/o ) {
+ if ($op eq '=' && $val =~ /^(\\.|[^\\*]*)*\*/o ) {
my $n = [];
my $type = 'initial';
- while ($val =~ s/^((\\.|[^\\*]+)*)\*+//) {
+ while ($val =~ s/^((\\.|[^\\*]*)*)\*//) {
push(@$n, { $type, _unescape("$1") }) # $1 is readonly, copy it
- if length $1;
+ if length($1) or $type eq 'any';
$type = 'any';
}
|