line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::Find::Rule; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
20848
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
86
|
|
4
|
2
|
|
|
2
|
|
11
|
use vars qw/$VERSION $AUTOLOAD/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
155
|
|
5
|
2
|
|
|
2
|
|
2123
|
use URI::Find; |
|
2
|
|
|
|
|
22972
|
|
|
2
|
|
|
|
|
156
|
|
6
|
2
|
|
|
2
|
|
19
|
use URI; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
7
|
2
|
|
|
2
|
|
1794
|
use Text::Glob 'glob_to_regex'; |
|
2
|
|
|
|
|
1793
|
|
|
2
|
|
|
|
|
132
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
3789
|
use Data::Dumper; |
|
2
|
|
|
|
|
18228
|
|
|
2
|
|
|
|
|
1337
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.8'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _force_object { |
14
|
77
|
|
|
77
|
|
134
|
my $object = shift; |
15
|
77
|
100
|
|
|
|
323
|
$object = $object->new() |
16
|
|
|
|
|
|
|
unless ref $object; |
17
|
77
|
|
|
|
|
1204
|
$object; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _flatten { |
21
|
39
|
|
|
39
|
|
51
|
my @flat; |
22
|
39
|
|
|
|
|
103
|
while (@_) { |
23
|
46
|
|
|
|
|
68
|
my $item = shift; |
24
|
46
|
100
|
|
|
|
195
|
ref $item eq 'ARRAY' ? push @_, @{ $item } : push @flat, $item; |
|
1
|
|
|
|
|
3
|
|
25
|
|
|
|
|
|
|
} |
26
|
39
|
|
|
|
|
986
|
return @flat; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub in { |
30
|
28
|
|
|
28
|
1
|
1151
|
my $self = _force_object shift; |
31
|
28
|
|
|
|
|
76
|
my ($anonsub, $return_objects) = @_; |
32
|
|
|
|
|
|
|
|
33
|
28
|
|
|
|
|
37
|
my @urls; |
34
|
|
|
|
|
|
|
my $sub = sub { |
35
|
308
|
|
|
308
|
|
125890
|
my ($original, $uri) = @_; |
36
|
308
|
|
|
|
|
1130
|
my $uri_object = URI->new($uri); |
37
|
308
|
|
|
|
|
16482
|
my $keep = 1; |
38
|
308
|
|
|
|
|
363
|
my $negate_next = 0; |
39
|
308
|
|
|
|
|
349
|
foreach my $i (@{ $self->{rules} }) { |
|
308
|
|
|
|
|
768
|
|
40
|
473
|
100
|
|
|
|
1112
|
if ($i->{rule} eq 'not') { |
41
|
44
|
|
|
|
|
75
|
$negate_next = 1; |
42
|
|
|
|
|
|
|
} else { |
43
|
429
|
|
|
|
|
499
|
my $result = &{$i->{code}}($original, $uri, $uri_object); |
|
429
|
|
|
|
|
18686
|
|
44
|
429
|
|
|
|
|
20625
|
$keep = $keep & ($negate_next ^ $result); |
45
|
429
|
|
|
|
|
1109
|
$negate_next = 0; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
308
|
100
|
|
|
|
700
|
if ($keep) { |
49
|
88
|
100
|
|
|
|
160
|
if ($return_objects) { |
50
|
10
|
|
|
|
|
20
|
push @urls, $uri_object; |
51
|
|
|
|
|
|
|
} else { |
52
|
78
|
|
|
|
|
214
|
push @urls, [$original, $uri]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
308
|
|
|
|
|
1194
|
return $original; |
56
|
28
|
|
|
|
|
144
|
}; |
57
|
28
|
|
|
|
|
156
|
my $finder = URI::Find->new($sub); |
58
|
28
|
|
|
|
|
539
|
$finder->find(\$anonsub); |
59
|
28
|
|
|
|
|
1564
|
return @urls; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
63
|
29
|
|
|
29
|
0
|
2797
|
my $referent = shift; |
64
|
29
|
|
66
|
|
|
152
|
my $class = ref $referent || $referent; |
65
|
29
|
|
|
|
|
177
|
my $self = bless { |
66
|
|
|
|
|
|
|
rules => [] |
67
|
|
|
|
|
|
|
}, $class; |
68
|
29
|
|
|
|
|
72
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub not { |
72
|
4
|
|
|
4
|
1
|
4792
|
my $self = _force_object shift; |
73
|
4
|
|
|
|
|
5
|
push @{ $self->{rules} }, { rule => 'not' }; |
|
4
|
|
|
|
|
20
|
|
74
|
4
|
|
|
|
|
143
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
*protocol=\&scheme; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub AUTOLOAD |
80
|
|
|
|
|
|
|
{ |
81
|
11
|
|
|
11
|
|
26332
|
(my $method = $AUTOLOAD) =~ s/^.*:://; |
82
|
11
|
50
|
|
|
|
46
|
return if $method eq 'DESTROY'; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# It would be nice to do this differently but I can't see any |
85
|
|
|
|
|
|
|
# easy way of working around the lack of object at this point. |
86
|
|
|
|
|
|
|
# Maybe it's best to rip this out entirely. |
87
|
11
|
100
|
|
|
|
1050
|
if (URI->new('http://x:y@a/b#c?d')->can($method)) { |
88
|
8
|
|
|
|
|
8675
|
my $code = <<'DEFINE_AUTO'; |
89
|
|
|
|
|
|
|
sub _FUNC_ { |
90
|
|
|
|
|
|
|
my $self = _force_object shift; |
91
|
|
|
|
|
|
|
my @names = map { ref $_ eq "Regexp" ? $_ : glob_to_regex $_ } _flatten( @_ ); |
92
|
|
|
|
|
|
|
my $regex = join( '|', @names ); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
push @{ $self->{rules} }, { |
95
|
|
|
|
|
|
|
rule => '_FUNC_', |
96
|
|
|
|
|
|
|
code => sub { ( $_[2]->_FUNC_() || '' )=~ /$regex/ }, |
97
|
|
|
|
|
|
|
args => \@_, |
98
|
|
|
|
|
|
|
}; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return $self; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
DEFINE_AUTO |
103
|
8
|
|
|
|
|
59
|
$code =~ s/_FUNC_/$method/g; |
104
|
8
|
50
|
50
|
209
|
0
|
1550
|
my $sub = eval $code; |
|
209
|
50
|
100
|
1
|
0
|
813
|
|
|
143
|
100
|
100
|
1
|
1
|
537
|
|
|
11
|
50
|
100
|
13
|
0
|
34
|
|
|
11
|
50
|
100
|
1
|
0
|
59
|
|
|
11
|
50
|
50
|
2
|
0
|
79
|
|
|
11
|
100
|
50
|
1
|
1
|
60
|
|
|
22
|
50
|
100
|
19
|
0
|
110
|
|
|
11
|
|
|
1
|
|
75
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
8
|
|
|
13
|
|
|
|
|
10786
|
|
|
13
|
|
|
|
|
46
|
|
|
18
|
|
|
|
|
82
|
|
|
13
|
|
|
|
|
452
|
|
|
13
|
|
|
|
|
21
|
|
|
13
|
|
|
|
|
102
|
|
|
13
|
|
|
|
|
149
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
3191
|
|
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
354
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
22
|
|
|
2
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
8
|
|
|
19
|
|
|
|
|
3902
|
|
|
19
|
|
|
|
|
81
|
|
|
20
|
|
|
|
|
111
|
|
|
19
|
|
|
|
|
2110
|
|
|
19
|
|
|
|
|
30
|
|
|
19
|
|
|
|
|
176
|
|
|
19
|
|
|
|
|
301
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
10
|
|
105
|
|
|
|
|
|
|
{ |
106
|
2
|
|
|
2
|
|
21
|
no strict 'refs'; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
201
|
|
|
8
|
|
|
|
|
17
|
|
107
|
8
|
|
|
|
|
281
|
return &$AUTOLOAD(@_); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} else { |
110
|
3
|
|
|
|
|
189
|
my $code = <<'DEFINE_SCHEME'; |
111
|
|
|
|
|
|
|
sub _FUNC_ { |
112
|
|
|
|
|
|
|
my $self = _force_object shift; |
113
|
|
|
|
|
|
|
if (@_) { |
114
|
|
|
|
|
|
|
$self->scheme('_FUNC_')->host(@_); |
115
|
|
|
|
|
|
|
} else { |
116
|
|
|
|
|
|
|
$self->scheme('_FUNC_'); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
DEFINE_SCHEME |
120
|
3
|
|
|
|
|
20
|
$code =~ s/_FUNC_/$method/g; |
121
|
3
|
50
|
|
1
|
0
|
297
|
eval $code; |
|
1
|
100
|
|
3
|
0
|
4
|
|
|
1
|
50
|
|
2
|
0
|
6
|
|
|
1
|
|
|
|
|
27
|
|
|
0
|
|
|
|
|
0
|
|
|
3
|
|
|
|
|
2632
|
|
|
3
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
46
|
|
|
1
|
|
|
|
|
27
|
|
|
2
|
|
|
|
|
2393
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
58
|
|
|
0
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
{ |
123
|
2
|
|
|
2
|
|
12
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
128
|
|
|
3
|
|
|
|
|
7
|
|
124
|
3
|
|
|
|
|
89
|
return &$AUTOLOAD(@_); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
__END__ |