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