| 1 | package HTML::MobileConverter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use HTML::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '0.011'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | my $self = {@_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | $self->init; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=7 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | $self->{maxlength} ||= 50000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"maxlength"} ||= 50000
MC/DC0%0/1
$self->{"maxlength"} ||= 50000
$self->{"maxlength"}
Truth table50%1/2
A
A= $self->{"maxlength"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | $self->{maxpctagcount} ||= 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"maxpctagcount"} ||= 10
MC/DC0%0/1
$self->{"maxpctagcount"} ||= 10
$self->{"maxpctagcount"}
Truth table50%1/2
A
A= $self->{"maxpctagcount"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | $self->{maxpctagrate} ||= 0.1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"maxpctagrate"} ||= "0.1"
MC/DC0%0/1
$self->{"maxpctagrate"} ||= "0.1"
$self->{"maxpctagrate"}
Truth table50%1/2
A
A= $self->{"maxpctagrate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | $self->{baseuri} or warn 'baseuri is not specified.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $self->{hrefhandler} ||= sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $href = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | return URI->new_abs($href, $self->{baseuri}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"hrefhandler"} ||= sub {
my $href = shift();
return "URI"->new_abs($href, $self->{"baseuri"});
}
MC/DC0%0/2
$self->{"hrefhandler"} ||= sub {
my $href = shift();
return "URI"->new_abs($href, $self->{"baseuri"});
}
$self->{"hrefhandler"}
sub {
my $href = shift();
return "URI"->new_abs($href, $self->{"baseuri"});
}
Truth table33%1/3
A ||= B
A= $self->{"hrefhandler"}B= sub {
my $href = shift();
return "URI"->new_abs($href, $self->{"baseuri"});
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | $self->{mobiletag} ||= { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | a => 'name|accesskey|href|cti|ijam|utn|subject|body|telbook|kana|email|ista|ilet|iswf|irst', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"mobiletag"} ||= {"a", "name|accesskey|href|cti|ijam|utn|subject|body|telbook|kana|email|ista|ilet|iswf|irst", "base", "href", "blink", "", "blockquote", "", "body", "bgcolor|text|link|alink|vlink", "br", "clear", "center", "", "dd", "", "dir", "type", "div", "align", "dl", "", "dt", "", "font", "color|size", "form", "action|method|utn", "head", "", "h1", "align", "h2", "align", "h3", "align", "h4", "align", "h5", "align", "h6", "align", "hr", "align|size|width|noshade|color", "html", "", "img", "src|align|width|height|hspace|vspace|alt", "input", "type|name|size|maxlength|accesskey|value|istyle|checked", "li", "type|value", "marquee", "behavior|direction|loop|height|width|scrollmount|scrolldelay|bgcolor", "menu", "type", "meta", "http\\-equiv|content", "object", "declare|id|data|type|width|height", "ol", "type|start", "option", "selected|value", "p", "align", "param", "name|value|valuetype", "plaintext", "", "pre", "", "select", "name|size|multiple", "textarea", "name|accesskey|rows|cols|istyle", "title", "", "ul", "type"}
MC/DC0%0/1
$self->{"mobiletag"} ||= {"a", "name|accesskey|href|cti|ijam|utn|subject|body|telbook|kana|email|ista|ilet|iswf|irst", "base", "href", "blink", "", "blockquote", "", "body", "bgcolor|text|link|alink|vlink", "br", "clear", "center", "", "dd", "", "dir", "type", "div", "align", "dl", "", "dt", "", "font", "color|size", "form", "action|method|utn", "head", "", "h1", "align", "h2", "align", "h3", "align", "h4", "align", "h5", "align", "h6", "align", "hr", "align|size|width|noshade|color", "html", "", "img", "src|align|width|height|hspace|vspace|alt", "input", "type|name|size|maxlength|accesskey|value|istyle|checked", "li", "type|value", "marquee", "behavior|direction|loop|height|width|scrollmount|scrolldelay|bgcolor", "menu", "type", "meta", "http\\-equiv|content", "object", "declare|id|data|type|width|height", "ol", "type|start", "option", "selected|value", "p", "align", "param", "name|value|valuetype", "plaintext", "", "pre", "", "select", "name|size|multiple", "textarea", "name|accesskey|rows|cols|istyle", "title", "", "ul", "type"}
$self->{"mobiletag"}
Truth table50%1/2
A
A= $self->{"mobiletag"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | base => 'href', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | blink => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | blockquote => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | body => 'bgcolor|text|link|alink|vlink', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | br => 'clear', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | center => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | dd => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | dir => 'type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | div => 'align', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | dl => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | dt => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | font => 'color|size', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | form => 'action|method|utn', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | head => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | h1 => 'align', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | h2 => 'align', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | h3 => 'align', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | h4 => 'align', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | h5 => 'align', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | h6 => 'align', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | hr => 'align|size|width|noshade|color', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | html => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | img => 'src|align|width|height|hspace|vspace|alt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | input => 'type|name|size|maxlength|accesskey|value|istyle|checked', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | li => 'type|value', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | marquee => 'behavior|direction|loop|height|width|scrollmount|scrolldelay|bgcolor', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | menu => 'type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | meta => 'http\-equiv|content', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | object => 'declare|id|data|type|width|height', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ol => 'type|start', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | option => 'selected|value', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | p => 'align', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | param => 'name|value|valuetype', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | plaintext => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | pre => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | select => 'name|size|multiple', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | textarea => 'name|accesskey|rows|cols|istyle', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | title => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ul => 'type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | $self->{codetag} = 'script|style'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | $self->{ignoretag} = 'form|input|select|option|textarea'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | $self->{html} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | ▶ | sub _initparser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initparser: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | $self->{html2} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | $self->{mhtml} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 5 | $self->{tagcount} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | $self->{mtagcount} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 5 | $self->{ismobilecontent} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 5 | $self->{iscode} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | $self->{parser} = HTML::Parser->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | api_version => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | handlers => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | start => [$self->starthandler, 'text, tagname, attr'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | end => [$self->endhandler, 'text, tagname'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | text => [$self->texthandler, 'text'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | default => [$self->defaulthandler, 'event, text'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 6 | ▶ | sub starthandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
starthandler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 9 | my ($text, $tag, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 9 | $self->{tagcount}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 9 | ▶ | if ($tag =~ /^($self->{codetag})$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | $self->{iscode}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 9 | ▶ | if (defined $self->{mobiletag}->{$tag}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | $self->{mtagcount}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 7 | ▶ | if ($tag =~ /^($self->{ignoretag})$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | $self->{mhtml} .= $self->_makestartm($tag,$attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | $self->{html2} .= $self->_makestart2($tag,$attr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 8 | ▶ | sub _makestartm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_makestartm: called CC=14 SCAR=31.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 8 | ▶ | my $tag = shift or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 8 | ▶ | my $attr = shift or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | ▶ | if ($tag eq 'img') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | my ($w,$h) = @$attr{'width', 'height'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | unless ($w && $h && $w < 100 && $h < 100) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$w and $h and $w < 100 and $h < 100
$w and $h and $w < 100
$w and $h
MC/DC0%0/4
$w and $h and $w < 100 and $h < 100
$w
$h
$w < 100
$h < 100
Truth table20%1/5
A and B and C and D
A= $wB= $hC= $w < 100D= $h < 100
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | my $text = 'img:'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | $text .= $attr->{alt} || $attr->{title} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$attr->{'alt'} || $attr->{'title'} || ''
$attr->{"alt"} or $attr->{"title"}
MC/DC0%0/2
$attr->{'alt'} || $attr->{'title'} || ''
$attr->{"alt"}
$attr->{"title"}
Truth table33%1/3
A or B
A= $attr->{"alt"}B= $attr->{"title"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 7 | my $attrpat = $self->{mobiletag}->{$tag}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 7 | my $text = qq|<$tag|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 7 | for my $key (keys %$attr) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | ▶ | if ($key =~ /^(href|action)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $text .= qq| $key="| . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | $self->{hrefhandler}($attr->{$key}) . '"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } elsif ($key eq 'src') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $text .= qq| $key="|. URI->new_abs($attr->{$key}, $self->{baseuri}) . '"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } elsif ($key =~ /^($attrpat)$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $text .= qq| $key="$attr->{$key}"|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 7 | $text .= '>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 7 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 8 | ▶ | sub _makestart2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_makestart2: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 8 | ▶ | my $tag = shift or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 8 | ▶ | my $attr = shift or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 8 | my $text = qq|<$tag|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 8 | for my $key (keys %$attr) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 7 | ▶ | if ($key =~ /^(href|action)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | $text .= qq| $key="| . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | $self->{hrefhandler}($attr->{$key}) . '"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } elsif ($key eq 'src') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | $text .= qq| $key="|. URI->new_abs($attr->{$key}, $self->{baseuri}) . '"'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | $text .= qq| $key="$attr->{$key}"|; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 8 | $text .= '>'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 8 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 6 | ▶ | sub endhandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endhandler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 9 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 9 | my ($text, $tag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 9 | ▶ | if ($tag =~ /^($self->{codetag})$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | $self->{iscode}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 9 | ▶ | if (defined $self->{mobiletag}->{$tag}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 7 | ▶ | if ($tag =~ /^($self->{ignoretag})$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $text = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | $self->{mhtml} .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7 | $self->{html2} .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | ▶ | sub texthandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
texthandler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 11 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 11 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 11 | ▶ | if (!$self->{iscode}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 10 | $self->{mhtml} .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 11 | $self->{html2} .= $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5 | ▶ | sub defaulthandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defaulthandler: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | ▶ | return sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | ▶ | sub convert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
convert: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | ▶ | $self->{html} = shift or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | $self->_initparser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | $self->{parser}->parse($self->{html}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | if ($self->_checkmobile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | return $self->{html2}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | return $self->{mhtml}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | ▶ | sub _checkmobile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_checkmobile: called CC=6 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 3 | ▶ | if ($self->{maxlength} && (length($self->{html}) > $self->{maxlength})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition33%1/3
$self->{"maxlength"} and length $self->{"html"} > $self->{"maxlength"}
MC/DC0%0/2
$self->{"maxlength"} and length $self->{"html"} > $self->{"maxlength"}
$self->{"maxlength"}
length $self->{"html"} > $self->{"maxlength"}
Truth table33%1/3
A and B
A= $self->{"maxlength"}B= length $self->{"html"} > $self->{"maxlength"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return; # over max size | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } elsif (($self->{tagcount} - $self->{mtagcount}) > $self->{maxpctagcount}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | return; # includes many pc tags | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } elsif (!$self->{tagcount}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # do nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } elsif (($self->{mtagcount} / $self->{tagcount}) < (1 - $self->{maxpctagrate})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | return; # includes many pc tags | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | $self->{ismobilecontent} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | return $self->ismobilecontent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | ▶ | sub ismobilecontent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ismobilecontent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 3 | return $self->{ismobilecontent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 15 | ▶ | sub param { $_[0]->{$_[1]}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
param: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||