| 1 | package Catalyst::Controller::Mobile::JP; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use base qw( Catalyst::Controller Class::Accessor::Fast ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | __PACKAGE__->mk_accessors(qw( encoding )); | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Encode::JP::Mobile ':props'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Encode::JP::Mobile::Character; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use HTTP::MobileAgent::Plugin::Charset; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | sub begin :Private { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
begin: called CC=10 SCAR=25.4
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | my ($self, $c) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 8 | $self->encoding(do { | |||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | my $encoding = $c->req->mobile_agent->encoding; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | ▶ | ref($encoding) && $encoding->isa('Encode::Encoding') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $encoding and $encoding->isa("Encode::Encoding")
MC/DC0%0/2
ref $encoding and $encoding->isa("Encode::Encoding")
ref $encoding
$encoding->isa("Encode::Encoding")
Truth table33%1/3
A and B
A= ref $encodingB= $encoding->isa("Encode::Encoding")
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | ? $encoding | ||||||||||||||||||||||||||||||||||||||||||
| 21 | : Encode::find_encoding($encoding); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | for my $value (values %{ $c->req->{parameters} }) { | |||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | next if ref $value && ref $value ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value and ref $value ne "ARRAY"
MC/DC0%0/2
ref $value and ref $value ne "ARRAY"
ref $value
ref $value ne "ARRAY"
Truth table33%1/3
A and B
A= ref $valueB= ref $value ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | ▶ | for my $v (ref($value) ? @$value : $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | ▶ | next if Encode::is_utf8($v); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $v = $self->encoding->decode($v); | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 8 | $c->res->content_type(do { | |||||||||||||||||||||||||||||||||||||||||
| 34 | 8 | ▶ | if ($c->req->mobile_agent->is_docomo) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | 'application/xhtml+xml'; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | 'text/html; charset=' . $self->encoding->mime_name; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | my %htmlspecialchars = ( '&' => '&', '<' => '<', '>' => '>', '"' => '"' ); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | my $htmlspecialchars = join '', keys %htmlspecialchars; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | our $decoding_content_type = qr{^text|xml$|javascript$}; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 8 | ▶ | sub end :Private { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end: called CC=4 SCAR=14.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | my ($self, $c) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | my $body = $c->res->body; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | ▶ | if ($body and | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$body and not ref $body and $c->res->content_type =~ /$Catalyst::Controller::Mobile::JP::decoding_content_type/
$body and not ref $body
MC/DC0%0/3
$body and not ref $body and $c->res->content_type =~ /$Catalyst::Controller::Mobile::JP::decoding_content_type/
$body
not ref $body
$c->res->content_type =~ /$Catalyst::Controller::Mobile::JP::decoding_content_type/
Truth table25%1/4
A and not(B) and C
A= $bodyB= not ref $bodyC= $c->res->content_type =~ /$Catalyst::Controller::Mobile::JP::decoding_content_type/
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | not ref($body) and | ||||||||||||||||||||||||||||||||||||||||||
| 53 | $c->res->content_type =~ $decoding_content_type) { | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 8 | ▶ | $body = $self->encoding->encode($body, sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | my $char = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | my $out = Encode::JP::Mobile::FB_CHARACTER()->($char); | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 8 | ▶ | if ($c->res->content_type =~ /html$|xml$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | $out =~ s/([$htmlspecialchars])/$htmlspecialchars{$1}/ego; # for (>3<) | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | $out; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 8 | }); | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | $c->res->body($body); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 71 | __END__ | ||||||||||||||||||||||||||||||||||||||||||