line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::elsquid; |
2
|
1
|
|
|
1
|
|
13751
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
3
|
use feature ':5.10'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
470
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw(parse_line); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub parse_line { # See: https://adblockplus.org/en/filters |
14
|
12
|
|
|
12
|
0
|
23
|
$_ = $_[0]; |
15
|
|
|
|
|
|
|
|
16
|
12
|
|
|
|
|
29
|
my $domchars = qr/[-a-zA-Z0-9.]+/; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
12
|
|
|
|
|
10
|
my $result = {}; # {} or { d => ... } or { u => ... } or { e => ... } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
12
|
100
|
|
|
|
34
|
return {} if /^\[/; |
23
|
11
|
100
|
|
|
|
22
|
return {} if /^!/; |
24
|
|
|
|
|
|
|
|
25
|
10
|
100
|
|
|
|
22
|
return {} if /^\@\@/; |
26
|
9
|
100
|
|
|
|
17
|
return {} if /#\@#/; |
27
|
|
|
|
|
|
|
|
28
|
8
|
100
|
|
|
|
18
|
return {} if /##/; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
7
|
100
|
|
|
|
69
|
if (/^\|\|($domchars)\^(\$|$)/) { |
33
|
2
|
|
|
|
|
20
|
return { d => $1 }; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
5
|
100
|
|
|
|
21
|
return {} if /\$/; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
4
|
return {} if m,^\|http://,; |
40
|
|
|
|
|
|
|
|
41
|
1
|
50
|
|
|
|
4
|
if (/^\|\|/) { |
42
|
1
|
|
|
|
|
3
|
s/^\|\|//; |
43
|
1
|
|
|
|
|
2
|
s/\^$//; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# URL (no ^ * |) ? |
47
|
1
|
50
|
33
|
|
|
47
|
if (/^$domchars\// && !/\^/ && !/\*/ && !/\|/ ) { |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
48
|
1
|
|
|
|
|
15
|
return { u => $_ } |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Must be expression now; eventually with ^ * | in it: |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $caret = "CCCCCC"; |
56
|
0
|
|
|
|
|
|
my $asterisk = "AAAAAA"; |
57
|
0
|
|
|
|
|
|
my $pipe = "PPPPPPP"; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
s/\^/$caret/g; |
60
|
0
|
|
|
|
|
|
s/\*/$asterisk/g; |
61
|
0
|
|
|
|
|
|
s/\|/$pipe/g; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$_ = quotemeta; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
s/$caret/[\/?]/; |
66
|
0
|
|
|
|
|
|
s/$asterisk/.*/g; |
67
|
0
|
|
|
|
|
|
s/$pipe$/\$/; |
68
|
0
|
|
|
|
|
|
s/$pipe//; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return { e => $_ }; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |