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