line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::LDAP::FilterBuilder; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
130668
|
$Net::LDAP::FilterBuilder::VERSION = '1.200001'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
25
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
47
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
116
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2284
|
use overload '""' => \&as_str; |
|
2
|
|
|
|
|
2008
|
|
|
2
|
|
|
|
|
15
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub escape { |
12
|
24
|
|
|
24
|
0
|
36
|
my $class = shift; |
13
|
24
|
|
|
|
|
36
|
my $value = shift; |
14
|
24
|
|
|
|
|
37
|
for ( $value ) { |
15
|
24
|
|
|
|
|
50
|
s{\\}{\\}g; |
16
|
24
|
|
|
|
|
41
|
s{\*}{\\*}g; |
17
|
24
|
|
|
|
|
33
|
s{\(}{\\(}g; |
18
|
24
|
|
|
|
|
32
|
s{\)}{\\)}g; |
19
|
24
|
|
|
|
|
44
|
s{\0}{\\0}g; |
20
|
|
|
|
|
|
|
} |
21
|
24
|
|
|
|
|
174
|
return $value; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
31
|
|
|
31
|
0
|
138
|
my $proto = shift; |
26
|
31
|
|
66
|
|
|
95
|
my $class = ref( $proto ) || $proto; |
27
|
|
|
|
|
|
|
|
28
|
31
|
|
|
|
|
49
|
my $filter; |
29
|
|
|
|
|
|
|
|
30
|
31
|
50
|
|
|
|
72
|
if ( @_ == 0 ) { |
|
|
100
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
$filter = '(objectclass=*)'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ( @_ == 1 ) { |
34
|
2
|
|
|
|
|
4
|
$filter = shift; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
29
|
100
|
|
|
|
55
|
my $op = @_ % 2 ? shift : '='; |
38
|
29
|
|
|
|
|
47
|
my @parts; |
39
|
29
|
|
|
|
|
76
|
while ( my ( $attr, $val ) = splice( @_, 0, 2 ) ) { |
40
|
30
|
100
|
|
|
|
69
|
if ( ref( $val ) eq 'ARRAY' ) { |
|
|
100
|
|
|
|
|
|
41
|
4
|
|
|
|
|
7
|
push @parts, sprintf( '(|%s)', join( q{}, map $class->new( $op, $attr, $_ ), @{ $val } ) ); |
|
4
|
|
|
|
|
24
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ( ref( $val ) eq 'SCALAR' ) { |
44
|
2
|
|
|
|
|
4
|
push @parts, sprintf( '(%s%s%s)', $attr, $op, ${ $val } ); |
|
2
|
|
|
|
|
13
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
24
|
|
|
|
|
50
|
push @parts, sprintf( '(%s%s%s)', $attr, $op, $class->escape( $val ) ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
29
|
100
|
|
|
|
63
|
if ( @parts > 1 ) { |
51
|
1
|
|
|
|
|
5
|
$filter = sprintf( '(&%s)', join( q{}, @parts ) ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
28
|
|
|
|
|
48
|
$filter = shift @parts; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
31
|
|
|
|
|
116
|
bless( \$filter, $class ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub or { |
62
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
3
|
|
|
|
|
6
|
${ $self } = sprintf( '(|%s%s)', $self, $self->new( @_ ) ); |
|
3
|
|
|
|
|
6
|
|
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
9
|
return $self; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub and { |
70
|
5
|
|
|
5
|
1
|
10
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
5
|
|
|
|
|
12
|
${ $self } = sprintf( '(&%s%s)', $self, $self->new( @_ ) ); |
|
5
|
|
|
|
|
9
|
|
73
|
|
|
|
|
|
|
|
74
|
5
|
|
|
|
|
15
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub not { |
78
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
2
|
|
|
|
|
6
|
${ $self } = sprintf( '(!%s)', $self ); |
|
2
|
|
|
|
|
4
|
|
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
5
|
return $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub as_str { |
86
|
41
|
|
|
41
|
1
|
115
|
${ $_[0] }; |
|
41
|
|
|
|
|
141
|
|
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# ABSTRACT: Build LDAP filter statements |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |