line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::ValuesAndExpressions::ProhibitEscapedCharacters; |
2
|
134
|
|
|
134
|
|
68198
|
use strict; |
|
134
|
|
|
|
|
184
|
|
|
134
|
|
|
|
|
3065
|
|
3
|
134
|
|
|
134
|
|
398
|
use warnings; |
|
134
|
|
|
|
|
139
|
|
|
134
|
|
|
|
|
2422
|
|
4
|
134
|
|
|
134
|
|
750
|
use Perl::Lint::Constants::Type; |
|
134
|
|
|
|
|
130
|
|
|
134
|
|
|
|
|
61048
|
|
5
|
134
|
|
|
134
|
|
540
|
use parent "Perl::Lint::Policy"; |
|
134
|
|
|
|
|
165
|
|
|
134
|
|
|
|
|
594
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
134
|
|
|
|
|
26798
|
DESC => 'Numeric escapes in interpolated string', |
9
|
|
|
|
|
|
|
EXPL => [54, 55], |
10
|
134
|
|
|
134
|
|
7182
|
}; |
|
134
|
|
|
|
|
153
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
5
|
|
|
5
|
0
|
8
|
my ($class, $file, $tokens, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
4
|
my @violations; |
16
|
5
|
|
|
|
|
5
|
my $is_reg_quote = 0; |
17
|
5
|
|
|
|
|
17
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
18
|
82
|
|
|
|
|
54
|
my $token_type = $token->{type}; |
19
|
82
|
100
|
100
|
|
|
265
|
if ($token_type == REG_QUOTE) { |
|
|
100
|
|
|
|
|
|
20
|
1
|
|
|
|
|
3
|
$is_reg_quote = 1; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
elsif ($token_type == STRING || $token_type == REG_EXP) { |
23
|
12
|
100
|
|
|
|
21
|
if ($is_reg_quote) { |
24
|
1
|
|
|
|
|
1
|
$is_reg_quote = 0; |
25
|
1
|
|
|
|
|
2
|
next; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
11
|
|
|
|
|
11
|
my $string = $token->{data}; |
29
|
11
|
100
|
|
|
|
33
|
if ($string =~ /\\x?[0-9a-fA-F]{2,}/) { |
30
|
|
|
|
|
|
|
push @violations, { |
31
|
|
|
|
|
|
|
filename => $file, |
32
|
|
|
|
|
|
|
line => $token->{line}, |
33
|
6
|
|
|
|
|
24
|
description => DESC, |
34
|
|
|
|
|
|
|
explanation => EXPL, |
35
|
|
|
|
|
|
|
policy => __PACKAGE__, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
16
|
return \@violations; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|