| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
use Moo; |
|
2
|
1
|
|
|
1
|
|
407
|
use Types::Standard qw( InstanceOf ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
3
|
1
|
|
|
1
|
|
244
|
use Encode 'find_encoding'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
4
|
1
|
|
|
1
|
|
382
|
|
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
244
|
|
|
5
|
|
|
|
|
|
|
has tx => ( |
|
6
|
|
|
|
|
|
|
required => 0, |
|
7
|
|
|
|
|
|
|
is => 'ro', |
|
8
|
|
|
|
|
|
|
isa => InstanceOf['Mojo::Transaction::HTTP'] |
|
9
|
|
|
|
|
|
|
); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has dom => ( |
|
12
|
|
|
|
|
|
|
required => 0, |
|
13
|
|
|
|
|
|
|
isa => InstanceOf['Mojo::DOM'], |
|
14
|
|
|
|
|
|
|
is => 'lazy', |
|
15
|
|
|
|
|
|
|
builder => 1, |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $tx = $_[0]->tx; |
|
19
|
|
|
|
|
|
|
my $dom = $tx->result->dom; |
|
20
|
0
|
|
|
0
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $charset; |
|
22
|
|
|
|
|
|
|
if ($tx->result->headers->content_type =~ /charset=(\S+)/) { |
|
23
|
0
|
|
|
|
|
|
$charset = $1; |
|
24
|
0
|
0
|
|
|
|
|
} elsif (my $el = $dom->at('meta[http-equiv="content-type" i]')) { |
|
|
|
0
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
if ($el->attr("content") =~ /\;\s*charset=(\S+)/i) { |
|
26
|
|
|
|
|
|
|
$charset = $1; |
|
27
|
0
|
0
|
|
|
|
|
} |
|
28
|
0
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if ($charset) { |
|
31
|
|
|
|
|
|
|
my $enc = find_encoding( $charset ); |
|
32
|
0
|
0
|
|
|
|
|
if ($enc) { |
|
33
|
0
|
|
|
|
|
|
my $body = $enc->decode($tx->result->body); |
|
34
|
0
|
0
|
|
|
|
|
$dom = Mojo::DOM->new($body); |
|
35
|
0
|
|
|
|
|
|
} |
|
36
|
0
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return $dom; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
0
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |