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