UserAgent/Base/Parsers.pm

filter: Statementstmt 1.6% 11 / 676 Branchbran 0.0% 0 / 338 Conditioncond 0.0% 0 / 264 MC/DCmcdc 0.0% 0 / 153 Subroutinesub 10.0% 3 / 30 Podpod n/a totaltotal 0.9% 14 / 1461 CC 270 SCAR 58.6
CC
270
Cov
1%
_parse_safari
1122.0
_parse_android
506.0
_parse_mozilla_family
462.0
CRAP 352.4
« UserAgent.pm ↑ Summary UserAgent/Base/Dumper.pm »
1 package Parse::HTTP::UserAgent::Base::Parsers;
2 4 $Parse::HTTP::UserAgent::Base::Parsers::VERSION = '0.43';
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Parse::HTTP::UserAgent::Constants qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶sub _extract_dotnet {
Subroutine _extract_dotnet: not called CC=8 SCAR=42.8
8 0 my($self, @args) = @_;
9 0 ▶ my @raw = map { ref($_) eq 'ARRAY' ? @{$_} : $_ } grep { $_ } @args;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
10 0 my(@extras,@dotnet);
11  
12 0 foreach my $e ( @raw ) {
13 0 ▶ if ( my @match = $e =~ RE_DOTNET ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@match) = $e =~ / \A [.]NET (?: \s+ CLR \s+ )? (.+?) \z /msx) 0 0 0
14 0 push @dotnet, $match[0];
15 0 next;
16 }
17 0 ▶ if ( $e =~ RE_WINDOWS_OS ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ / \A Win(dows|NT|[0-9]+)? /imsx) 0 0 0
18 0 ▶ if ( $1 && $1 ne '64' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 and $1 ne 64) 0 0 0
Condition0%0/3
$1 and $1 ne 64
!ll&&!rl&&r
000
MC/DC0%0/2
$1 and $1 ne 64
$1 $1 ne 64
Truth table0%0/3
A and B
A= $1B= $1 ne 64
ABresult
0X0
100
111
19 # Maxthon stupidity: multiple OS definitions
20 0 ▶ $self->[UA_OS] ||= $e;
Condition0%0/3
$self->[26] ||= $e
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->[26] ||= $e
$self->[26] $e
Truth table0%0/3
A ||= B
A= $self->[26]B= $e
ABresult
1X1
011
000
21 0 next;
22 }
23 }
24 0 push @extras, $e;
25 }
26  
27 0 return [@extras], [@dotnet];
28 }
29  
30 0 ▶sub _fix_opera {
Subroutine _fix_opera: not called CC=5 SCAR=34.0
31 0 my $self = shift;
32 0 ▶ return 1 if ! $self->[UA_EXTRAS];
Branch: 1 branch
BranchTrueFalseTotal
unless $self->[26] 0 0 0
33 0 my @buf;
34 0 foreach my $e ( @{ $self->[UA_EXTRAS] } ) {
35 0 ▶ if ( $e =~ RE_OPERA_MINI ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ m[ \A (Opera \s+ Mini) / (.+?) \z ]msx) 0 0 0
36 0 $self->[UA_ORIGINAL_NAME] = $1;
37 0 $self->[UA_ORIGINAL_VERSION] = $2;
38 0 $self->[UA_MOBILE] = 1;
39 0 next;
40 }
41 0 push @buf, $e;
42 }
43 0 $self->_fix_os_lang;
44 0 $self->_fix_windows_nt('skip_os');
45 0 ▶ $self->[UA_EXTRAS] = @buf ? [ @buf ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@buf ? : 0 0 0
46 0 return 1;
47 }
48  
49 0 ▶sub _fix_generic {
Subroutine _fix_generic: not called CC=5 SCAR=34.0
50 0 my($self, $os_ref, $name_ref, $v_ref, $e_ref) = @_;
51 0 ▶ if ( ${$v_ref} && ${$v_ref} !~ RE_DIGIT) {
Branch: 1 branch
BranchTrueFalseTotal
if (${$v_ref;} and not ${$v_ref;} =~ / [0-9] /msx) 0 0 0
Condition0%0/3
${$v_ref;} and not ${$v_ref;} =~ / [0-9] /msx
!ll&&!rl&&r
000
MC/DC0%0/2
${$v_ref;} and not ${$v_ref;} =~ / [0-9] /msx
${$v_ref;} not ${$v_ref;} =~ / [0-9] /msx
Truth table0%0/3
A and not(B)
A= ${$v_ref;}B= not ${$v_ref;} =~ / [0-9] /msx
ABresult
0X0
100
111
52 0 ${$name_ref} .= q{ } . ${$v_ref};
53 0 ${$v_ref} = undef;
54 }
55  
56 0 ▶ if ( ${$os_ref} && ${$os_ref} =~ RE_HTTP ) {
Branch: 1 branch
BranchTrueFalseTotal
if (${$os_ref;} and ${$os_ref;} =~ m[ http:// ]msx) 0 0 0
Condition0%0/3
${$os_ref;} and ${$os_ref;} =~ m[ http:// ]msx
!ll&&!rl&&r
000
MC/DC0%0/2
${$os_ref;} and ${$os_ref;} =~ m[ http:// ]msx
${$os_ref;} ${$os_ref;} =~ m[ http:// ]msx
Truth table0%0/3
A and B
A= ${$os_ref;}B= ${$os_ref;} =~ m[ http:// ]msx
ABresult
0X0
100
111
57 0 ${$os_ref} =~ s{ \A \+ }{}xms;
58 0 push @{ $e_ref }, ${$os_ref};
59 0 ${$os_ref} = undef;
60 }
61 0 return;
62 }
63  
64 0 ▶sub _parse_maxthon {
Subroutine _parse_maxthon: not called CC=19 SCAR=59.4
65 0 my($self, $moz, $thing, $extra, @others) = @_;
66 0 ▶ my $is_30 = $extra
Condition0%0/6
$extra && $extra->[0] && index($extra->[0], 'AppleWebKit') != -1
!ll&&!rl&&r
000
$extra and $extra->[0]
!ll&&!rl&&r
000
MC/DC0%0/3
$extra && $extra->[0] && index($extra->[0], 'AppleWebKit') != -1
$extra $extra->[0] index($extra->[0], 'AppleWebKit') != -1
Truth table0%0/4
A and B && C
A= $extraB= $extra->[0]C= index($extra->[0], 'AppleWebKit') != -1
ABCresult
0XX0
10X0
1100
1111
67 && $extra->[0]
68 && index( $extra->[0], 'AppleWebKit' ) != NO_IMATCH;
69 0 my($maxthon, $msie, @buf);
70  
71 0 ▶ if ( $is_30 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_30) { } 0 0 0
72 # yay, new nonsense with the new version
73 0 my @new;
74 0 for my $i (0..$#others) {
75 0 ▶ if ( index( $others[$i], 'Maxthon') != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($others[$i], "Maxthon") != -1) 0 0 0
76 0 @new = split m{\s+}xms, $others[$i];
77 0 $maxthon = shift @new;
78 0 ▶ $extra ||= [];
Condition0%0/2
$extra ||= []
l!l
00
MC/DC0%0/1
$extra ||= []
$extra
Truth table0%0/2
A
A= $extra
Aresult
11
00
79 0 unshift @{ $extra }, shift @new;
80 0 $others[$i] = '';
81 0 last;
82 }
83 }
84 0 @others = grep { $_ } @others, @new;
85 0 $self->_parse_safari( $moz, $thing, $extra, @others );
86 0 $self->[UA_NAME] = 'Maxthon';
87 }
88 else {
89 0 my @omap = grep { $_ } map { split RE_SC_WS_MULTI, $_ } @others;
90  
91 0 foreach my $e ( @omap, @{$thing} ) { # $extra -> junk
92 0 ▶ if ( index(uc $e, 'MAXTHON') != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index(uc $e, "MAXTHON") != -1) 0 0 0
93 0 $maxthon = $e;
94 0 next;
95 }
96 0 ▶ if ( index(uc $e, 'MSIE' ) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index(uc $e, "MSIE") != -1) 0 0 0
97 # Maxthon stupidity: multiple MSIE strings
98 0 ▶ $msie ||= $e;
Condition0%0/3
$msie ||= $e
l!l&&r!l&&!r
000
MC/DC0%0/2
$msie ||= $e
$msie $e
Truth table0%0/3
A ||= B
A= $msieB= $e
ABresult
1X1
011
000
99 0 next;
100 }
101 0 push @buf, $e;
102 }
103 }
104  
105 0 ▶ if ( ! $maxthon ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($maxthon) 0 0 0
106 0 warn ERROR_MAXTHON_VERSION . "\n";
107 0 $self->[UA_UNKNOWN] = 1;
108 0 return;
109 }
110  
111 0 ▶ if ( $is_30 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_30) { } 0 0 0
112 0 ▶ if ( $self->[UA_LANG] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26]) 0 0 0
113 0 ▶ push @{ $self->[UA_EXTRAS] ||= [] }, $self->[UA_LANG];
Condition0%0/2
$self->[26] ||= []
l!l
00
MC/DC0%0/1
$self->[26] ||= []
$self->[26]
Truth table0%0/2
A
A= $self->[26]
Aresult
11
00
114 0 $self->[UA_LANG] = undef;
115 }
116 }
117 else {
118 0 ▶ if ( ! $msie ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($msie) 0 0 0
119 0 warn ERROR_MAXTHON_MSIE . "\n";
120 0 $self->[UA_UNKNOWN] = 1;
121 0 return;
122 }
123 $self->_parse_msie(
124 0 $moz, [ undef, @buf ], undef, split RE_WHITESPACE, $msie
125 );
126 }
127  
128 0 ▶ my(undef, $mv) = split $is_30 ? RE_SLASH : RE_WHITESPACE, $maxthon;
Branch: 1 branch
BranchTrueFalseTotal
$is_30 ? : 0 0 0
129 my $v = $mv ? $mv
130 : $maxthon ? '1.0'
131 0 ▶ : do { warn ERROR_MAXTHON_VERSION . "\n"; 0 }
Branch: 2 branches
BranchTrueFalseTotal
$mv ? : 0 0 0
$maxthon ? : 0 0 0
132 ;
133  
134 0 $self->[UA_ORIGINAL_VERSION] = $v;
135 0 $self->[UA_ORIGINAL_NAME] = 'Maxthon';
136 0 $self->[UA_PARSER] = 'maxthon';
137 0 return 1;
138 }
139  
140 0 ▶sub _parse_msie {
Subroutine _parse_msie: not called CC=16 SCAR=56.1
141 0 my($self, $moz, $thing, $extra, $name, $version) = @_;
142 0 my $junk = shift @{ $thing }; # already used
143  
144 0 my($extras,$dotnet) = $self->_extract_dotnet( $thing, $extra );
145  
146 0 ▶ if ( @{$extras} == 2 && index( $extras->[1], 'Lunascape' ) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$extras;} == 2 and index($extras->[1], "Lunascape") != -1) 0 0 0
Condition0%0/3
@{$extras;} == 2 and index($extras->[1], "Lunascape") != -1
!ll&&!rl&&r
000
MC/DC0%0/2
@{$extras;} == 2 and index($extras->[1], "Lunascape") != -1
@{$extras;} == 2 index($extras->[1], "Lunascape") != -1
Truth table0%0/3
A and B
A= @{$extras;} == 2B= index($extras->[1], "Lunascape") != -1
ABresult
0X0
100
111
147 0 ($name, $version) = split RE_CHAR_SLASH_WS, pop @{ $extras };
148 }
149  
150 0 $self->[UA_NAME] = $name;
151 0 $self->[UA_VERSION_RAW] = $version;
152 0 ▶ $self->[UA_DOTNET] = [ @{ $dotnet } ] if @{$dotnet};
Branch: 1 branch
BranchTrueFalseTotal
if @{$dotnet;} 0 0 0
153  
154 0 ▶ if ( $extras->[0] && $extras->[0] eq 'Mac_PowerPC' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extras->[0] and $extras->[0] eq "Mac_PowerPC") 0 0 0
Condition0%0/3
$extras->[0] and $extras->[0] eq "Mac_PowerPC"
!ll&&!rl&&r
000
MC/DC0%0/2
$extras->[0] and $extras->[0] eq "Mac_PowerPC"
$extras->[0] $extras->[0] eq "Mac_PowerPC"
Truth table0%0/3
A and B
A= $extras->[0]B= $extras->[0] eq "Mac_PowerPC"
ABresult
0X0
100
111
155 0 $self->[UA_OS] = shift @{ $extras };
156 }
157  
158 0 my $real_version;
159 my @buf;
160 0 foreach my $e ( @{ $extras } ) {
161 0 ▶ if ( index( $e, 'Trident/' ) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($e, "Trident/") != -1) 0 0 0
162 0 my($tk_name, $tk_version) = split m{[/]}xms, $e, 2;
163 0 $self->[UA_TOOLKIT] = [ $tk_name, $tk_version ];
164 0 ▶ if ( $tk_name eq 'Trident' && $tk_version ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tk_name eq "Trident" and $tk_version) 0 0 0
Condition0%0/3
$tk_name eq "Trident" and $tk_version
!ll&&!rl&&r
000
MC/DC0%0/2
$tk_name eq "Trident" and $tk_version
$tk_name eq "Trident" $tk_version
Truth table0%0/3
A and B
A= $tk_name eq "Trident"B= $tk_version
ABresult
0X0
100
111
165 0 ▶ if ( $tk_version eq '7.0' && $self->[UA_VERSION_RAW] ne '11.0' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tk_version eq '7.0' and $self->[26] ne '11.0') { } 0 0 0
elsif ($tk_version eq '6.0' and $self->[26] ne '10.0') { } 0 0 0
Condition0%0/3
$tk_version eq "7.0" and $self->[26] ne "11.0"
!ll&&!rl&&r
000
MC/DC0%0/2
$tk_version eq "7.0" and $self->[26] ne "11.0"
$tk_version eq "7.0" $self->[26] ne "11.0"
Truth table0%0/3
A and B
A= $tk_version eq "7.0"B= $self->[26] ne "11.0"
ABresult
0X0
100
111
166 # more stupidity (compat mode)
167 0 $self->[UA_ORIGINAL_NAME] = 'MSIE';
168 0 $self->[UA_ORIGINAL_VERSION] = 11;
169 }
170 ▶ elsif ( $tk_version eq '6.0' && $self->[UA_VERSION_RAW] ne '10.0') {
Condition0%0/3
$tk_version eq "6.0" and $self->[26] ne "10.0"
!ll&&!rl&&r
000
MC/DC0%0/2
$tk_version eq "6.0" and $self->[26] ne "10.0"
$tk_version eq "6.0" $self->[26] ne "10.0"
Truth table0%0/3
A and B
A= $tk_version eq "6.0"B= $self->[26] ne "10.0"
ABresult
0X0
100
111
171 # more stupidity (compat mode)
172 0 $self->[UA_ORIGINAL_NAME] = 'MSIE';
173 0 $self->[UA_ORIGINAL_VERSION] = 10;
174 }
175 else {
176 # must be the real version or some other stupidity
177 }
178 }
179 0 next;
180 }
181 0 push @buf, $e;
182 }
183  
184 my @extras =
185 map {
186 0 my $thing = $self->trim( $_ );
187 lc($thing) eq 'touch'
188 0 ▶ ? do {
Branch: 1 branch
BranchTrueFalseTotal
lc $thing eq 'touch' ? : 0 0 0
189 0 $self->[UA_TOUCH] = 1;
190 0 $self->[UA_MOBILE] = 1;
191 0 ();
192 }
193 : $thing
194 ;
195 }
196 0 grep { $_ !~ m{ \s+ compatible \z }xms }
197 @buf
198 ;
199  
200 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
201 0 $self->[UA_PARSER] = 'msie';
202  
203 0 return 1;
204 }
205  
206 0 ▶sub _parse_msie_11 {
Subroutine _parse_msie_11: not called CC=10 SCAR=47.0
207 0 my($self, $moz, $thing, $extra) = @_;
208  
209 0 ▶ if ( ref $extra eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $extra eq 'ARRAY') { } 0 0 0
210 # remove junk
211 0 ▶ @{$extra} = grep { $_ ne 'like' && $_ ne 'Gecko' } @{ $extra };
Condition0%0/3
$_ ne 'like' && $_ ne 'Gecko'
!ll&&!rl&&r
000
MC/DC0%0/2
$_ ne 'like' && $_ ne 'Gecko'
$_ ne 'like' $_ ne 'Gecko'
Truth table0%0/3
A && B
A= $_ ne 'like'B= $_ ne 'Gecko'
ABresult
0X0
100
111
212 }
213 else {
214 0 $extra = [];
215 }
216  
217 0 my($version);
218 0 ▶ while ( my $e = shift @{ $thing } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = shift @{$thing;}) 0 0 0
219 0 ▶ if ( index($e, 'rv:' ) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($e, "rv:") != -1) 0 0 0
220 0 $version = (split m{rv:}xms, $e )[1] ;
221 0 next;
222 }
223 0 push @{ $extra }, $e;
224 }
225  
226 0 ▶ $self->_parse_msie( undef, $thing, $extra, 'MSIE', $version) || return;
Branch: 1 branch
BranchTrueFalseTotal
$self->_parse_msie(undef, $thing, $extra, "MSIE", $version) or return 0 0 0
227  
228 0 ▶ if ( $self->[UA_TOUCH] && $self->[UA_EXTRAS] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26] and $self->[26]) 0 0 0
Condition0%0/3
$self->[26] and $self->[26]
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[26] and $self->[26]
$self->[26] $self->[26]
Truth table0%0/3
A and B
A= $self->[26]B= $self->[26]
ABresult
0X0
100
111
229 # version 10+
230 my @extras = map {
231 $_ eq 'ARM'
232 0 ▶ ? do {
Branch: 1 branch
BranchTrueFalseTotal
$_ eq 'ARM' ? : 0 0 0
233 0 $self->[UA_DEVICE] = $_;
234 ()
235 0 }
236 : $_
237 0 } @{ $self->[UA_EXTRAS] };
238 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
239 }
240  
241 0 $self->[UA_PARSER] = 'msie11';
242 0 return 1;
243 }
244  
245 0 ▶sub _parse_firefox {
Subroutine _parse_firefox: not called CC=4 SCAR=30.0
246 0 my($self, @args) = @_;
247 0 $self->_parse_mozilla_family( @args );
248 0 my $e = $self->[UA_EXTRAS];
249  
250 0 ▶ if ( ref $e eq 'ARRAY'
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e eq "ARRAY" and @{$e;} > 0 and index(lc $e->[-1], "fennec") != -1) 0 0 0
Condition0%0/6
ref $e eq "ARRAY" and @{$e;} > 0 and index(lc $e->[-1], "fennec") != -1
!ll&&!rl&&r
000
ref $e eq "ARRAY" and @{$e;} > 0
!ll&&!rl&&r
000
MC/DC0%0/3
ref $e eq "ARRAY" and @{$e;} > 0 and index(lc $e->[-1], "fennec") != -1
ref $e eq "ARRAY" @{$e;} > 0 index(lc $e->[-1], "fennec") != -1
Truth table0%0/4
A and B and C
A= ref $e eq "ARRAY"B= @{$e;} > 0C= index(lc $e->[-1], "fennec") != -1
ABCresult
0XX0
10X0
1100
1111
251 0 && @{ $e } > 0
252 && index( lc $e->[-1], 'fennec' ) != NO_IMATCH
253 ) {
254 0 $self->_fix_fennec( $e );
255 }
256  
257 0 $self->[UA_NAME] = 'Firefox';
258  
259 0 return 1;
260 }
261  
262 0 ▶sub _parse_ff_suspect {
Subroutine _parse_ff_suspect: not called CC=1 SCAR=6.9
263 0 my($self, $moz, $thing, $extra, @others) = @_;
264 # fool the moz parser
265 0 unshift @{ $extra }, '';
266  
267 0 $self->_parse_mozilla_family( $moz, $thing, $extra, @others );
268  
269 0 $self->[UA_PARSER] = 'ff_suspect';
270  
271 0 return 1;
272 }
273  
274 0 ▶sub _fix_fennec {
Subroutine _fix_fennec: not called CC=5 SCAR=34.0
275 0 my($self, $e) = @_;
276 0 my($name, $version) = split RE_SLASH, pop @{ $e };
277 0 $self->[UA_ORIGINAL_NAME] = $name;
278 0 $self->[UA_ORIGINAL_VERSION] = $version;
279 0 $self->[UA_MOBILE] = 1;
280 0 ▶ return if ! $self->[UA_LANG];
Branch: 1 branch
BranchTrueFalseTotal
unless $self->[26] 0 0 0
281  
282 0 ▶ if ( lc $self->[UA_LANG] eq 'tablet' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (lc $self->[26] eq 'tablet') { } 0 0 0
elsif (index($self->[26], ' ') != -1) { } 0 0 0
283 0 $self->[UA_TABLET] = 1;
284 0 $self->[UA_LANG] = undef;
285 }
286 elsif ( index( $self->[UA_LANG], q{ } ) != NO_IMATCH ) {
287 0 ▶ push @{ $self->[UA_EXTRAS] ||= [] }, $self->[UA_LANG];
Condition0%0/2
$self->[26] ||= []
l!l
00
MC/DC0%0/1
$self->[26] ||= []
$self->[26]
Truth table0%0/2
A
A= $self->[26]
Aresult
11
00
288 0 $self->[UA_LANG] = undef;
289 }
290 else {
291 # Do nothing
292 }
293  
294 0 return;
295 }
296  
297 0 ▶sub _parse_safari {
Subroutine _parse_safari: not called CC=33 SCAR=70.2
298 0 my($self, $moz, $thing, $extra, @others) = @_;
299 0 ▶ my $ipad = $thing && lc( $thing->[0] || q{} ) eq 'ipad';
Condition0%0/5
$thing && lc($thing->[0] || '') eq 'ipad'
!ll&&!rl&&r
000
$thing->[0] || ''
l!l
00
MC/DC0%0/2
$thing && lc($thing->[0] || '') eq 'ipad'
$thing $thing->[0]
Truth table0%0/3
A && B
A= $thingB= $thing->[0]
ABresult
0X0
100
111
300 0 my($version, @junk) = split RE_WHITESPACE, pop @others;
301 0 ▶ my $ep = $version &&
Condition0%0/3
$version && index(lc $version, 'epiphany') != -1
!ll&&!rl&&r
000
MC/DC0%0/2
$version && index(lc $version, 'epiphany') != -1
$version index(lc $version, 'epiphany') != -1
Truth table0%0/3
A && B
A= $versionB= index(lc $version, 'epiphany') != -1
ABresult
0X0
100
111
302 index( lc($version), 'epiphany' ) != NO_IMATCH;
303 0 my($junkv, $vx) = split RE_SLASH, $version;
304  
305 0 ▶ if ( $ipad ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ipad) 0 0 0
306 0 shift @{ $thing }; # remove iPad
307 0 ▶ if ( $junkv && $junkv eq 'Mobile' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($junkv and $junkv eq "Mobile") 0 0 0
Condition0%0/3
$junkv and $junkv eq "Mobile"
!ll&&!rl&&r
000
MC/DC0%0/2
$junkv and $junkv eq "Mobile"
$junkv $junkv eq "Mobile"
Truth table0%0/3
A and B
A= $junkvB= $junkv eq "Mobile"
ABresult
0X0
100
111
308 0 unshift @junk, join q{/}, $junkv, $vx;
309 0 $vx = undef;
310 }
311 0 $self->[UA_MOBILE] = 1;
312 0 $self->[UA_TABLET] = 1;
313 }
314  
315 0 ▶ $self->[UA_NAME] = $ep ? 'Epiphany'
Branch: 2 branches
BranchTrueFalseTotal
$ep ? : 0 0 0
$ipad ? : 0 0 0
316 : $ipad ? 'iPad'
317 : 'Safari';
318 0 $self->[UA_VERSION_RAW] = $vx;
319 0 ▶ $self->[UA_TOOLKIT] = $extra ? [ split RE_SLASH, shift @{ $extra } ] : [];
Branch: 1 branch
BranchTrueFalseTotal
$extra ? : 0 0 0
320 0 ▶ if ( $thing->[-1] && length($thing->[LAST_ELEMENT]) <= 5 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thing->[-1] and length $thing->[-1] <= 5) 0 0 0
Condition0%0/3
$thing->[-1] and length $thing->[-1] <= 5
!ll&&!rl&&r
000
MC/DC0%0/2
$thing->[-1] and length $thing->[-1] <= 5
$thing->[-1] length $thing->[-1] <= 5
Truth table0%0/3
A and B
A= $thing->[-1]B= length $thing->[-1] <= 5
ABresult
0X0
100
111
321 # todo: $self->_is_lang_field($junk)
322 # in here or in _post_parse()
323 0 $self->[UA_LANG] = pop @{ $thing };
324 }
325 0 $self->[UA_OS] = @{$thing} && length $thing->[LAST_ELEMENT] > 1
326 0 ? pop @{ $thing }
327 0 ▶ : shift @{ $thing }
Branch: 1 branch
BranchTrueFalseTotal
@{$thing;} && length $thing->[-1] > 1 ? : 0 0 0
Condition0%0/3
@{$thing;} and length $thing->[-1] > 1
!ll&&!rl&&r
000
MC/DC0%0/2
@{$thing;} and length $thing->[-1] > 1
@{$thing;} length $thing->[-1] > 1
Truth table0%0/3
A and B
A= @{$thing;}B= length $thing->[-1] > 1
ABresult
0X0
100
111
328 ;
329 0 ▶ if ( $self->[UA_OS] && lc $self->[UA_OS] eq 'macintosh' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26] and lc $self->[26] eq "macintosh") 0 0 0
Condition0%0/3
$self->[26] and lc $self->[26] eq "macintosh"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[26] and lc $self->[26] eq "macintosh"
$self->[26] lc $self->[26] eq "macintosh"
Truth table0%0/3
A and B
A= $self->[26]B= lc $self->[26] eq "macintosh"
ABresult
0X0
100
111
330 0 $self->[UA_OS] = $self->[UA_LANG];
331 0 $self->[UA_LANG] = undef;
332 }
333  
334 0 ▶ if ( $thing->[0] && lc $thing->[0] eq 'iphone' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thing->[0] and lc $thing->[0] eq "iphone") 0 0 0
Condition0%0/3
$thing->[0] and lc $thing->[0] eq "iphone"
!ll&&!rl&&r
000
MC/DC0%0/2
$thing->[0] and lc $thing->[0] eq "iphone"
$thing->[0] lc $thing->[0] eq "iphone"
Truth table0%0/3
A and B
A= $thing->[0]B= lc $thing->[0] eq "iphone"
ABresult
0X0
100
111
335 0 $self->[UA_MOBILE] = 1;
336 0 $self->[UA_DEVICE] = shift @{$thing};
337 0 my $check_os = $thing->[LAST_ELEMENT];
338  
339 0 ▶ if ( $check_os && index( $check_os, 'Mac OS X' ) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($check_os and index($check_os, "Mac OS X") != -1) 0 0 0
Condition0%0/3
$check_os and index($check_os, "Mac OS X") != -1
!ll&&!rl&&r
000
MC/DC0%0/2
$check_os and index($check_os, "Mac OS X") != -1
$check_os index($check_os, "Mac OS X") != -1
Truth table0%0/3
A and B
A= $check_osB= index($check_os, "Mac OS X") != -1
ABresult
0X0
100
111
340 0 ▶ if ( $self->[UA_OS] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26]) 0 0 0
341 0 ▶ push @{ $self->[UA_EXTRAS] ||= [] }, $self->[UA_OS];
Condition0%0/2
$self->[26] ||= []
l!l
00
MC/DC0%0/1
$self->[26] ||= []
$self->[26]
Truth table0%0/2
A
A= $self->[26]
Aresult
11
00
342 }
343 0 $self->[UA_OS] = pop @{ $thing };
344 # Another oddity: tk as "AppleWebKit/en_SG"
345 0 ▶ if ( ! $self->[UA_LANG] && $self->[UA_TOOLKIT] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->[26] and $self->[26]) 0 0 0
Condition0%0/3
not $self->[26] and $self->[26]
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->[26] and $self->[26]
not $self->[26] $self->[26]
Truth table0%0/3
not(A) and B
A= not $self->[26]B= $self->[26]
ABresult
0X0
100
111
346 0 my $v = $self->[UA_TOOLKIT][TK_ORIGINAL_VERSION];
347 0 ▶ if ( $v && $v =~ m< [a-zA-Z]{2}_[a-zA-Z]{2} >xms ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v and $v =~ / [a-zA-Z]{2}_[a-zA-Z]{2} /msx) 0 0 0
Condition0%0/3
$v and $v =~ / [a-zA-Z]{2}_[a-zA-Z]{2} /msx
!ll&&!rl&&r
000
MC/DC0%0/2
$v and $v =~ / [a-zA-Z]{2}_[a-zA-Z]{2} /msx
$v $v =~ / [a-zA-Z]{2}_[a-zA-Z]{2} /msx
Truth table0%0/3
A and B
A= $vB= $v =~ / [a-zA-Z]{2}_[a-zA-Z]{2} /msx
ABresult
0X0
100
111
348 0 $self->[UA_LANG] = $v;
349 0 $self->[UA_TOOLKIT][TK_ORIGINAL_VERSION] = undef;
350 }
351 }
352 }
353 }
354  
355 0 my @extras;
356 0 push @extras, @{$thing}, @others;
357  
358 0 ▶ if ( $self->[UA_OS] && length($self->[UA_OS]) == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26] and length $self->[26] == 1) 0 0 0
Condition0%0/3
$self->[26] and length $self->[26] == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[26] and length $self->[26] == 1
$self->[26] length $self->[26] == 1
Truth table0%0/3
A and B
A= $self->[26]B= length $self->[26] == 1
ABresult
0X0
100
111
359 0 push @extras, $self->[UA_OS];
360 0 $self->[UA_OS] = undef;
361 }
362  
363 0 ▶ if ( $self->[UA_LANG] && $self->[UA_LANG] !~ m{[a-zA-Z]+}xmsg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26] and not $self->[26] =~ /[a-zA-Z]+/gmsx) 0 0 0
Condition0%0/3
$self->[26] and not $self->[26] =~ /[a-zA-Z]+/gmsx
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[26] and not $self->[26] =~ /[a-zA-Z]+/gmsx
$self->[26] not $self->[26] =~ /[a-zA-Z]+/gmsx
Truth table0%0/3
A and not(B)
A= $self->[26]B= not $self->[26] =~ /[a-zA-Z]+/gmsx
ABresult
0X0
100
111
364 # some junk like "6.0" -- more stupidity
365 0 push @extras, $self->[UA_LANG];
366 0 $self->[UA_LANG] = undef;
367 }
368  
369 0 ▶ push @extras, @junk if @junk;
Branch: 1 branch
BranchTrueFalseTotal
if @junk 0 0 0
370 0 ▶ push @extras, @{$extra} if $extra;
Branch: 1 branch
BranchTrueFalseTotal
if $extra 0 0 0
371  
372 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
373  
374 0 return 1;
375 }
376  
377 0 ▶sub _parse_chrome {
Subroutine _parse_chrome: not called CC=6 SCAR=37.4
378 0 my($self, $moz, $thing, $extra, @others) = @_;
379 0 my $chx = pop @others;
380 0 my($chrome, $safari, @rest) = split RE_WHITESPACE, $chx;
381 0 my $opera;
382 0 ▶ if ( $rest[0] && index( $rest[0], 'OPR/', 0) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest[0] and index($rest[0], 'OPR/', 0) != -1) { } 0 0 0
Condition0%0/3
$rest[0] and index($rest[0], "OPR/", 0) != -1
!ll&&!rl&&r
000
MC/DC0%0/2
$rest[0] and index($rest[0], "OPR/", 0) != -1
$rest[0] index($rest[0], "OPR/", 0) != -1
Truth table0%0/3
A and B
A= $rest[0]B= index($rest[0], "OPR/", 0) != -1
ABresult
0X0
100
111
383 0 $opera = shift @rest;
384 0 ▶ if ( ref $extra eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $extra eq "ARRAY") 0 0 0
385 0 unshift @{ $extra }, $chrome;
386 }
387 0 push @others, @rest, $safari;
388 }
389 else {
390 0 push @others, $safari;
391 }
392 0 $self->_parse_safari($moz, $thing, $extra, @others);
393 0 ▶ my($name, $version) = split RE_SLASH, $opera || $chrome;
Condition0%0/3
$opera || $chrome
l!l&&r!l&&!r
000
MC/DC0%0/2
$opera || $chrome
$opera $chrome
Truth table0%0/3
A || B
A= $operaB= $chrome
ABresult
1X1
011
000
394 0 ▶ $self->[UA_NAME] = $opera ? 'Opera' : $name;
Branch: 1 branch
BranchTrueFalseTotal
$opera ? : 0 0 0
395 0 $self->[UA_VERSION_RAW] = $version;
396 0 return 1;
397 }
398  
399 0 ▶sub _parse_android {
Subroutine _parse_android: not called CC=22 SCAR=62.3
400 0 my($self, $moz, $thing, $extra, @others) = @_;
401 0 (undef, @{$self}[UA_STRENGTH, UA_OS, UA_LANG, UA_DEVICE]) = @{ $thing };
402 0 ▶ if ( ! $extra
Branch: 1 branch
BranchTrueFalseTotal
if (not $extra and $others[0] and index($others[0], "AppleWebKit") != -1) 0 0 0
Condition0%0/6
not $extra and $others[0] and index($others[0], "AppleWebKit") != -1
!ll&&!rl&&r
000
not $extra and $others[0]
!ll&&!rl&&r
000
MC/DC0%0/3
not $extra and $others[0] and index($others[0], "AppleWebKit") != -1
not $extra $others[0] index($others[0], "AppleWebKit") != -1
Truth table0%0/4
not(A) and B and C
A= not $extraB= $others[0]C= index($others[0], "AppleWebKit") != -1
ABCresult
0XX0
10X0
1100
1111
403 && $others[0]
404 && index( $others[0], 'AppleWebKit' ) != NO_IMATCH
405 ) {
406 0 $extra = [ shift @others ];
407 0 $self->[UA_PARSER] = 'android:paren_fixer';
408 }
409 0 ▶ $self->[UA_TOOLKIT] = [ split RE_SLASH, $extra->[0] ] if $extra;
Branch: 1 branch
BranchTrueFalseTotal
if $extra 0 0 0
410 0 my(@extras, $is_phone);
411  
412 0 my @junkions = map { split m{\s+}xms } @others;
413 0 foreach my $junk ( @junkions ) {
414 0 ▶ if ( $junk eq 'Mobile' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($junk eq "Mobile") 0 0 0
415 0 $is_phone = 1;
416 0 next;
417 }
418 0 ▶ if ( index( $junk, 'Version' ) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($junk, "Version") != -1) 0 0 0
419 0 my(undef, $v) = split RE_SLASH, $junk;
420 0 $self->[UA_VERSION_RAW] = $v; # looks_like_number?
421 0 next;
422 }
423 0 push @extras, $junk;
424 }
425  
426 0 ▶ if ( $self->[UA_DEVICE] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26]) 0 0 0
427 0 my @build = split RE_WHITESPACE, $self->[UA_DEVICE];
428 0 my @btest;
429 0 ▶ while ( @build && index($build[-1], 'Build') == NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@build and index($build[-1], "Build") == -1) 0 0 0
Condition0%0/3
@build and index($build[-1], "Build") == -1
!ll&&!rl&&r
000
MC/DC0%0/2
@build and index($build[-1], "Build") == -1
@build index($build[-1], "Build") == -1
Truth table0%0/3
A and B
A= @buildB= index($build[-1], "Build") == -1
ABresult
0X0
100
111
430 0 unshift @btest, pop @build;
431 }
432 0 ▶ unshift @btest, pop @build if @build;
Branch: 1 branch
BranchTrueFalseTotal
if @build 0 0 0
433 0 ▶ my $device = @build ? join ' ', @build : undef;
Branch: 1 branch
BranchTrueFalseTotal
@build ? : 0 0 0
434 0 my $build = shift @btest;
435  
436 0 ▶ if ( $device && $build ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($device and $build) 0 0 0
Condition0%0/3
$device and $build
!ll&&!rl&&r
000
MC/DC0%0/2
$device and $build
$device $build
Truth table0%0/3
A and B
A= $deviceB= $build
ABresult
0X0
100
111
437 0 $build =~ s{ Build/ }{}xms;
438 0 ▶ my $os = $self->[UA_OS] || 'Android';
Condition0%0/2
$self->[26] || 'Android'
l!l
00
MC/DC0%0/1
$self->[26] || 'Android'
$self->[26]
Truth table0%0/2
A
A= $self->[26]
Aresult
11
00
439 0 $self->[UA_DEVICE] = $device;
440 0 $self->[UA_OS] = "$os ($build)";
441 0 ▶ if ( @btest ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@btest) 0 0 0
442 0 $self->[UA_TOOLKIT] = [ split RE_SLASH, $btest[0] ];
443 }
444 }
445 }
446  
447 0 ▶ if ( @extras >= 3 && $extras[0] && $extras[0] eq 'KHTML,') {
Branch: 1 branch
BranchTrueFalseTotal
if (@extras >= 3 and $extras[0] and $extras[0] eq "KHTML,") 0 0 0
Condition0%0/6
@extras >= 3 and $extras[0] and $extras[0] eq "KHTML,"
!ll&&!rl&&r
000
@extras >= 3 and $extras[0]
!ll&&!rl&&r
000
MC/DC0%0/3
@extras >= 3 and $extras[0] and $extras[0] eq "KHTML,"
@extras >= 3 $extras[0] $extras[0] eq "KHTML,"
Truth table0%0/4
A and B and C
A= @extras >= 3B= $extras[0]C= $extras[0] eq "KHTML,"
ABCresult
0XX0
10X0
1100
1111
448 0 unshift @extras, join ' ', map { shift @extras } 1..3;
449 }
450  
451 0 my @extras_final = grep { $_ } @extras;
452  
453 0 $self->[UA_NAME] = 'Android';
454 0 $self->[UA_MOBILE] = 1;
455 0 ▶ $self->[UA_TABLET] = $is_phone ? undef : 1;
Branch: 1 branch
BranchTrueFalseTotal
$is_phone ? : 0 0 0
456 0 ▶ $self->[UA_EXTRAS] = @extras_final ? [ @extras_final ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras_final ? : 0 0 0
457  
458 0 return 1;
459 }
460  
461 0 ▶sub _parse_opera_pre {
Subroutine _parse_opera_pre: not called CC=20 SCAR=60.4
462 # opera 5,9
463 0 my($self, $moz, $thing, $extra) = @_;
464 0 my $ffaker = @{$thing} && index($thing->[LAST_ELEMENT], 'rv:') != NO_IMATCH
465 0 ▶ ? pop @{$thing}
Branch: 1 branch
BranchTrueFalseTotal
@{$thing;} && index($thing->[-1], 'rv:') != -1 ? : 0 0 0
Condition0%0/3
@{$thing;} and index($thing->[-1], "rv:") != -1
!ll&&!rl&&r
000
MC/DC0%0/2
@{$thing;} and index($thing->[-1], "rv:") != -1
@{$thing;} index($thing->[-1], "rv:") != -1
Truth table0%0/3
A and B
A= @{$thing;}B= index($thing->[-1], "rv:") != -1
ABresult
0X0
100
111
466 : 0;
467 0 my($name, $version) = split RE_SLASH, $moz;
468 0 ▶ return if $name ne 'Opera';
Branch: 1 branch
BranchTrueFalseTotal
if $name ne "Opera" 0 0 0
469 0 $self->[UA_NAME] = $name;
470 0 $self->[UA_VERSION_RAW] = $version;
471 0 my $lang;
472  
473 0 ▶ if ( $extra ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra) 0 0 0
474 # opera changed version string to workaround lame browser sniffers
475 # http://dev.opera.com/articles/view/opera-ua-string-changes/
476 0 ▶ my $swap = @{$extra}
Condition0%0/3
@{$extra;} && index($extra->[-1], 'Version/') != -1
!ll&&!rl&&r
000
MC/DC0%0/2
@{$extra;} && index($extra->[-1], 'Version/') != -1
@{$extra;} index($extra->[-1], 'Version/') != -1
Truth table0%0/3
A && B
A= @{$extra;}B= index($extra->[-1], 'Version/') != -1
ABresult
0X0
100
111
477 && index($extra->[LAST_ELEMENT], 'Version/') != NO_IMATCH;
478 0 ▶ ($lang = $swap ? shift @{$extra} : pop @{$extra}) =~ tr/[]//d;
Branch: 1 branch
BranchTrueFalseTotal
$swap ? : 0 0 0
479 0 ▶ if ( $swap ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($swap) 0 0 0
480 0 my $vjunk = pop @{$extra};
481 0 ▶ $self->[UA_VERSION_RAW] = ( split RE_SLASH, $vjunk )[1] if $vjunk;
Branch: 1 branch
BranchTrueFalseTotal
if $vjunk 0 0 0
482 }
483 }
484  
485 0 ▶ $lang ||= pop @{$thing} if $ffaker;
Branch: 1 branch
BranchTrueFalseTotal
if $ffaker 0 0 0
Condition0%0/3
$lang ||= pop @{$thing;}
l!l&&r!l&&!r
000
MC/DC0%0/2
$lang ||= pop @{$thing;}
$lang pop @{$thing;}
Truth table0%0/3
A ||= B
A= $langB= pop @{$thing;}
ABresult
1X1
011
000
486  
487 0 ▶ my $tk_parsed_as_lang = ! $self->[UA_TOOLKIT]
Condition0%0/9
!$self->[26] && $self->_numify($version) >= 9 && $lang && length $lang > 5
!ll&&!rl&&r
000
not $self->[26] and $self->_numify($version) >= 9 and $lang
!ll&&!rl&&r
000
not $self->[26] and $self->_numify($version) >= 9
!ll&&!rl&&r
000
MC/DC0%0/4
!$self->[26] && $self->_numify($version) >= 9 && $lang && length $lang > 5
not $self->[26] $self->_numify($version) >= 9 $lang length $lang > 5
Truth table0%0/5
not(A) and B and C && D
A= not $self->[26]B= $self->_numify($version) >= 9C= $langD= length $lang > 5
ABCDresult
0XXX0
10XX0
110X0
11100
11111
488 && $self->_numify( $version ) >= OPERA9
489 && $lang
490 && length( $lang ) > OPERA_TK_LENGTH;
491  
492 0 ▶ if ( $tk_parsed_as_lang ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tk_parsed_as_lang) 0 0 0
493 0 $self->[UA_TOOLKIT] = [ split RE_SLASH, $lang ];
494 0 ▶ ($lang = pop @{$thing}) =~ tr/[]//d if $extra;
Branch: 1 branch
BranchTrueFalseTotal
if $extra 0 0 0
495 }
496  
497 0 $self->[UA_LANG] = $lang;
498  
499 0 ▶ if ( @{$thing} && $self->_is_strength( $thing->[LAST_ELEMENT] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$thing;} and $self->_is_strength($thing->[-1])) { } 0 0 0
Condition0%0/3
@{$thing;} and $self->_is_strength($thing->[-1])
!ll&&!rl&&r
000
MC/DC0%0/2
@{$thing;} and $self->_is_strength($thing->[-1])
@{$thing;} $self->_is_strength($thing->[-1])
Truth table0%0/3
A and B
A= @{$thing;}B= $self->_is_strength($thing->[-1])
ABresult
0X0
100
111
500 0 $self->[UA_STRENGTH] = pop @{ $thing };
501 0 $self->[UA_OS] = shift @{ $thing };
502 }
503 else {
504 0 $self->[UA_OS] = pop @{ $thing };
505 }
506  
507 0 ▶ my @extras = ( @{ $thing }, ( $extra ? @{$extra} : () ) );
Branch: 1 branch
BranchTrueFalseTotal
$extra ? : 0 0 0
508  
509 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
510  
511 0 return $self->_fix_opera;
512 }
513  
514 0 ▶sub _parse_opera_post {
Subroutine _parse_opera_post: not called CC=7 SCAR=40.3
515 # opera 5,6,7
516 0 my($self, $moz, $thing, $extra, $compatible) = @_;
517 0 ▶ shift @{ $thing } if $compatible;
Branch: 1 branch
BranchTrueFalseTotal
if $compatible 0 0 0
518 0 $self->[UA_NAME] = shift @{$extra};
519 0 $self->[UA_VERSION_RAW] = shift @{$extra};
520 0 ▶ ($self->[UA_LANG] = shift @{$extra} || q{}) =~ tr/[]//d;
Condition0%0/2
shift @{$extra;} || ''
l!l
00
MC/DC0%0/1
shift @{$extra;} || ''
shift @{$extra;}
Truth table0%0/2
A
A= shift @{$extra;}
Aresult
11
00
521  
522 0 ▶ if ( @{$thing} && $self->_is_strength( $thing->[LAST_ELEMENT] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$thing;} and $self->_is_strength($thing->[-1])) { } 0 0 0
Condition0%0/3
@{$thing;} and $self->_is_strength($thing->[-1])
!ll&&!rl&&r
000
MC/DC0%0/2
@{$thing;} and $self->_is_strength($thing->[-1])
@{$thing;} $self->_is_strength($thing->[-1])
Truth table0%0/3
A and B
A= @{$thing;}B= $self->_is_strength($thing->[-1])
ABresult
0X0
100
111
523 0 $self->[UA_STRENGTH] = pop @{ $thing };
524 0 $self->[UA_OS] = shift @{ $thing };
525 }
526 else {
527 0 $self->[UA_OS] = pop @{ $thing };
528 }
529  
530 0 ▶ my @extras = ( @{ $thing }, ( $extra ? @{$extra} : () ) );
Branch: 1 branch
BranchTrueFalseTotal
$extra ? : 0 0 0
531 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
532 0 return $self->_fix_opera;
533 }
534  
535 0 ▶sub _parse_mozilla_family {
Subroutine _parse_mozilla_family: not called CC=21 SCAR=61.4
536 0 my($self, $moz, $thing, $extra, @others) = @_;
537 # firefox variation or just mozilla itself
538 0 ▶ my($name, $version) = split RE_SLASH, defined $extra->[1] ? $extra->[1]
Branch: 1 branch
BranchTrueFalseTotal
defined $extra->[1] ? : 0 0 0
539 : $moz
540 ;
541 0 ▶ if ( $version ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 0 0 0
542 0 $extra->[1] = '';
543 }
544 0 $self->[UA_NAME] = $name;
545 0 $self->[UA_VERSION_RAW] = $version;
546 $self->[UA_TOOLKIT] = $extra->[0]
547 0 ▶ ? [ split RE_SLASH, shift @{ $extra } ]
Branch: 1 branch
BranchTrueFalseTotal
$extra->[0] ? : 0 0 0
548 : undef
549 ;
550  
551 0 ▶ if ( @{$thing} && index($thing->[LAST_ELEMENT], 'rv:') != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$thing;} and index($thing->[-1], "rv:") != -1) 0 0 0
Condition0%0/3
@{$thing;} and index($thing->[-1], "rv:") != -1
!ll&&!rl&&r
000
MC/DC0%0/2
@{$thing;} and index($thing->[-1], "rv:") != -1
@{$thing;} index($thing->[-1], "rv:") != -1
Truth table0%0/3
A and B
A= @{$thing;}B= index($thing->[-1], "rv:") != -1
ABresult
0X0
100
111
552 0 $self->[UA_MOZILLA] = pop @{ $thing };
553 0 my $len_thing = @{ $thing };
554 0 ▶ if ( $len_thing == 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($len_thing == 3) { } 0 0 0
elsif ($len_thing <= 2) { } 0 0 0
555 0 $self->[UA_OS] = shift @{ $thing };
556 0 ▶ if ( $self->[UA_OS] && $self->[UA_OS] eq 'Macintosh' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26] and $self->[26] eq "Macintosh") 0 0 0
Condition0%0/3
$self->[26] and $self->[26] eq "Macintosh"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[26] and $self->[26] eq "Macintosh"
$self->[26] $self->[26] eq "Macintosh"
Truth table0%0/3
A and B
A= $self->[26]B= $self->[26] eq "Macintosh"
ABresult
0X0
100
111
557 0 $self->[UA_OS] = shift @{ $thing };
558 }
559 0 ▶ $self->[UA_LANG] = pop @{ $thing } if @{ $thing };
Branch: 1 branch
BranchTrueFalseTotal
if @{$thing;} 0 0 0
560 }
561 elsif ( $len_thing <= 2 ) {
562 0 ▶ if ( $thing->[0] eq 'X11'
Branch: 2 branches
BranchTrueFalseTotal
if ($thing->[0] eq 'X11' or index($thing->[-1], 'Intel') != -1) { } 0 0 0
elsif (index(lc $thing->[0], 'android') != -1 or index(lc $thing->[0], 'maemo') != -1) { } 0 0 0
Condition0%0/3
$thing->[0] eq "X11" or index($thing->[-1], "Intel") != -1
l!l&&r!l&&!r
000
MC/DC0%0/2
$thing->[0] eq "X11" or index($thing->[-1], "Intel") != -1
$thing->[0] eq "X11" index($thing->[-1], "Intel") != -1
Truth table0%0/3
A or B
A= $thing->[0] eq "X11"B= index($thing->[-1], "Intel") != -1
ABresult
1X1
011
000
563 || index( $thing->[-1], 'Intel' ) != NO_IMATCH
564 ) {
565 0 ▶ if ( index( lc $thing->[-1], 'linux arm') != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index(lc $thing->[-1], 'linux arm') != -1) { } 0 0 0
566 0 $self->[UA_DEVICE] = pop @{ $thing };
567 0 $self->[UA_OS] = 'Linux'; # Android? huh?
568 }
569 else {
570 0 $self->[UA_OS] = pop @{ $thing };
571 }
572 }
573 ▶ elsif (
Condition0%0/3
index(lc $thing->[0], "android") != -1 or index(lc $thing->[0], "maemo") != -1
l!l&&r!l&&!r
000
MC/DC0%0/2
index(lc $thing->[0], "android") != -1 or index(lc $thing->[0], "maemo") != -1
index(lc $thing->[0], "android") != -1 index(lc $thing->[0], "maemo") != -1
Truth table0%0/3
A or B
A= index(lc $thing->[0], "android") != -1B= index(lc $thing->[0], "maemo") != -1
ABresult
1X1
011
000
574 index( lc $thing->[0], 'android' ) != NO_IMATCH
575 || index( lc $thing->[0], 'maemo' ) != NO_IMATCH
576 ) {
577 # mobile? tablet?
578 0 $self->[UA_OS] = shift @{ $thing };
579 0 $self->[UA_DEVICE] = shift @{ $thing };
580 0 ▶ if ( lc $self->[UA_DEVICE] eq 'tablet' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $self->[26] eq "tablet") 0 0 0
581 0 $self->[UA_TABLET] = 1;
582 }
583 }
584 else {
585 0 ▶ if ( $len_thing > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len_thing > 1) { } 0 0 0
586 0 ▶ if ( $thing->[-1] ne 'WOW64' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thing->[-1] ne "WOW64") 0 0 0
587 0 $self->[UA_LANG] = pop @{ $thing };
588 }
589 }
590 else {
591 0 $self->[UA_OS] = pop @{ $thing };
592 }
593 }
594 }
595 else {
596  
597 0 $self->[UA_LANG] = pop @{ $thing };
598 0 $self->[UA_OS] = pop @{ $thing };
599 }
600 }
601  
602 0 my @extras = grep { $_ }
603 0 ▶ @{ $thing },
Branch: 1 branch
BranchTrueFalseTotal
$extra ? : 0 0 0
604 @others,
605 0 $extra ? @{ $extra } : (),
606 ;
607  
608 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
609  
610 0 return 1;
611 }
612  
613 0 ▶sub _parse_gecko {
Subroutine _parse_gecko: not called CC=21 SCAR=61.4
614 0 my($self, $moz, $thing, $extra, @others) = @_;
615 0 $self->_parse_mozilla_family($moz, $thing, $extra, @others);
616  
617 # we got some name & version
618 0 ▶ if ( $self->[UA_NAME] && $self->[UA_VERSION_RAW] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26] and $self->[26]) 0 0 0
Condition0%0/3
$self->[26] and $self->[26]
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[26] and $self->[26]
$self->[26] $self->[26]
Truth table0%0/3
A and B
A= $self->[26]B= $self->[26]
ABresult
0X0
100
111
619 # Change SeaMonkey too?
620 0 my $before = $self->[UA_NAME];
621 0 ▶ $self->[UA_NAME] = 'Netscape' if $self->[UA_NAME] eq 'Netscape6';
Branch: 1 branch
BranchTrueFalseTotal
if $self->[26] eq "Netscape6" 0 0 0
622 0 ▶ $self->[UA_NAME] = 'Mozilla' if $self->[UA_NAME] eq 'Beonex';
Branch: 1 branch
BranchTrueFalseTotal
if $self->[26] eq "Beonex" 0 0 0
623 0 $self->[UA_PARSER] = 'mozilla_family:generic';
624 0 my @buf;
625  
626 0 foreach my $e ( @{ $self->[UA_EXTRAS] } ) {
627 0 ▶ next if ! $e;
Branch: 1 branch
BranchTrueFalseTotal
unless $e 0 0 0
628 0 ▶ if ( my $s = $self->_is_strength($e) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $s = $self->_is_strength($e)) 0 0 0
629 0 $self->[UA_STRENGTH] = $s;
630 0 next;
631 }
632 0 ▶ if ( $e =~ RE_IX86 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ / \s i\d86 /msx) 0 0 0
633 0 my($os,$lang) = split RE_COMMA, $e;
634 0 ▶ $self->[UA_OS] = $os if $os;
Branch: 1 branch
BranchTrueFalseTotal
if $os 0 0 0
635 0 ▶ $self->[UA_LANG] = $self->trim($lang) if $lang;
Branch: 1 branch
BranchTrueFalseTotal
if $lang 0 0 0
636 0 next;
637 }
638 0 ▶ if ( ! $self->[UA_OS] && $e =~ m{ Win(?:NT|dows) }xmsi ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->[26] and $e =~ / Win(?:NT|dows) /imsx) 0 0 0
Condition0%0/3
not $self->[26] and $e =~ / Win(?:NT|dows) /imsx
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->[26] and $e =~ / Win(?:NT|dows) /imsx
not $self->[26] $e =~ / Win(?:NT|dows) /imsx
Truth table0%0/3
not(A) and B
A= not $self->[26]B= $e =~ / Win(?:NT|dows) /imsx
ABresult
0X0
100
111
639 0 $self->[UA_OS] = $e;
640 0 next;
641 }
642 0 ▶ if ( $e =~ RE_TWO_LETTER_LANG ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ / \A [a-z]{2} \z /msx) 0 0 0
643 0 $self->[UA_LANG] = $e;
644 0 next;
645 }
646 0 ▶ if ( $e =~ RE_EPIPHANY_GECKO ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ m[ \A (Epiphany) / (.+?) \z ]imsx) 0 0 0
647 0 $self->[UA_NAME] = $before = $1;
648 0 $self->[UA_VERSION_RAW] = $2;
649 }
650 0 push @buf, $e;
651 }
652  
653 0 ▶ $self->[UA_EXTRAS] = @buf ? [ @buf ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@buf ? : 0 0 0
654 0 ▶ $self->[UA_ORIGINAL_NAME] = $before if $before ne $self->[UA_NAME];
Branch: 1 branch
BranchTrueFalseTotal
if $before ne $self->[26] 0 0 0
655 0 $self->_fix_windows_nt;
656 0 return 1 ;
657 }
658  
659 0 ▶ if ( ref $self->[UA_TOOLKIT] eq 'ARRAY' && $self->[UA_TOOLKIT][TK_NAME] eq 'Gecko' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->[26] eq "ARRAY" and $self->[26][0] eq "Gecko") 0 0 0
Condition0%0/3
ref $self->[26] eq "ARRAY" and $self->[26][0] eq "Gecko"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $self->[26] eq "ARRAY" and $self->[26][0] eq "Gecko"
ref $self->[26] eq "ARRAY" $self->[26][0] eq "Gecko"
Truth table0%0/3
A and B
A= ref $self->[26] eq "ARRAY"B= $self->[26][0] eq "Gecko"
ABresult
0X0
100
111
660 0 ($self->[UA_NAME], $self->[UA_VERSION_RAW]) = split RE_SLASH, $moz;
661 0 ▶ if ( $self->[UA_NAME] && $self->[UA_VERSION_RAW] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26] and $self->[26]) 0 0 0
Condition0%0/3
$self->[26] and $self->[26]
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[26] and $self->[26]
$self->[26] $self->[26]
Truth table0%0/3
A and B
A= $self->[26]B= $self->[26]
ABresult
0X0
100
111
662 0 $self->[UA_PARSER] = 'mozilla_family:gecko';
663 0 return 1;
664 }
665 }
666  
667 0 return;
668 }
669  
670 0 ▶sub _fix_os_lang {
Subroutine _fix_os_lang: not called CC=3 SCAR=24.8
671 0 my $self = shift;
672 0 ▶ if ( $self->[UA_OS] && length $self->[UA_OS] == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[26] and length $self->[26] == 2) 0 0 0
Condition0%0/3
$self->[26] and length $self->[26] == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$self->[26] and length $self->[26] == 2
$self->[26] length $self->[26] == 2
Truth table0%0/3
A and B
A= $self->[26]B= length $self->[26] == 2
ABresult
0X0
100
111
673 0 $self->[UA_LANG] = $self->[UA_OS];
674 0 $self->[UA_OS] = undef;
675 }
676 0 return;
677 }
678  
679 0 ▶sub _fix_windows_nt {
Subroutine _fix_windows_nt: not called CC=9 SCAR=45.0
680 0 my $self = shift;
681 0 my $skip_os = shift; # ie os can be undef
682 0 ▶ my $os = $self->[UA_OS] || q{};
Condition0%0/2
$self->[26] || ''
l!l
00
MC/DC0%0/1
$self->[26] || ''
$self->[26]
Truth table0%0/2
A
A= $self->[26]
Aresult
11
00
683 0 ▶ return if ( ! $os && ! $skip_os )
Branch: 1 branch
BranchTrueFalseTotal
if not $os || $skip_os or $os ne "windows" and not $skip_os or ref $self->[26] ne "ARRAY" or not $self->[26][0] or not $self->[26][0] =~ / NT\s?(\d.*?) \z /imsx 0 0 0
Condition0%0/18
not $os || $skip_os or $os ne "windows" and not $skip_os or ref $self->[26] ne "ARRAY" or not $self->[26][0] or not $self->[26][0] =~ / NT\s?(\d.*?) \z /imsx
l!l&&r!l&&!r
000
not $os || $skip_os or $os ne "windows" and not $skip_os or ref $self->[26] ne "ARRAY" or not $self->[26][0]
l!l&&r!l&&!r
000
not $os || $skip_os or $os ne "windows" and not $skip_os or ref $self->[26] ne "ARRAY"
l!l&&r!l&&!r
000
not $os || $skip_os or $os ne "windows" and not $skip_os
l!l&&r!l&&!r
000
$os || $skip_os
l!l&&r!l&&!r
000
$os ne "windows" and not $skip_os
!ll&&!rl&&r
000
MC/DC0%0/7
not $os || $skip_os or $os ne "windows" and not $skip_os or ref $self->[26] ne "ARRAY" or not $self->[26][0] or not $self->[26][0] =~ / NT\s?(\d.*?) \z /imsx
$os $skip_os $os ne "windows" not $skip_os ref $self->[26] ne "ARRAY" not $self->[26][0] not $self->[26][0] =~ / NT\s?(\d.*?) \z /imsx
Truth table0%0/19
not(A || B) or C and not(D) or E or not(F) or not(G)
A= $osB= $skip_osC= $os ne "windows"D= not $skip_osE= ref $self->[26] ne "ARRAY"F= not $self->[26][0]G= not $self->[26][0] =~ / NT\s?(\d.*?) \z /imsx
ABCDEFGresult
00XXXXX1
1X11XXX1
0111XXX1
1X0X1XX1
1X101XX1
010X1XX1
01101XX1
1X0X01X1
1X1001X1
010X01X1
011001X1
1X0X0011
1X100011
010X0011
01100011
1X0X0000
1X100000
010X0000
01100000
684 || ( $os ne 'windows' && ! $skip_os )
685 || ref $self->[UA_EXTRAS] ne 'ARRAY'
686 || ! $self->[UA_EXTRAS][0]
687 || $self->[UA_EXTRAS][0] !~ m{ NT\s?(\d.*?) \z }xmsi
688 ;
689 0 $self->[UA_EXTRAS][0] = $self->[UA_OS]; # restore
690 0 $self->[UA_OS] = "Windows NT $1"; # fix
691 0 return;
692 }
693  
694 0 ▶sub _parse_netscape {
Subroutine _parse_netscape: not called CC=7 SCAR=40.3
695 0 my($self, $moz, $thing) = @_;
696 0 my($mozx, $junk) = split RE_WHITESPACE, $moz;
697 0 my(undef, $version) = split RE_SLASH , $mozx;
698 0 my @buf;
699 0 foreach my $e ( @{ $thing } ) {
700 0 ▶ if ( my $s = $self->_is_strength($e) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $s = $self->_is_strength($e)) 0 0 0
701 0 $self->[UA_STRENGTH] = $s;
702 0 next;
703 }
704 0 push @buf, $e;
705 }
706 0 $self->[UA_VERSION_RAW] = $version;
707 0 ▶ $self->[UA_OS] = $buf[0] eq 'X11' ? pop @buf : shift @buf;
Branch: 1 branch
BranchTrueFalseTotal
$buf[0] eq 'X11' ? : 0 0 0
708 0 $self->[UA_NAME] = 'Netscape';
709 0 ▶ $self->[UA_EXTRAS] = @buf ? [ @buf ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@buf ? : 0 0 0
710 0 ▶ if ( $junk ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($junk) 0 0 0
711 0 $junk =~ s{ \[ (.+?) \] .* \z}{$1}xms;
712 0 ▶ $self->[UA_LANG] = $junk if $junk;
Branch: 1 branch
BranchTrueFalseTotal
if $junk 0 0 0
713 }
714 0 $self->[UA_PARSER] = 'netscape';
715 0 return 1;
716 }
717  
718 0 ▶sub _generic_moz_thing {
Subroutine _generic_moz_thing: not called CC=17 SCAR=57.2
719 0 my($self, $moz, $t, $extra, $compatible, @others) = @_;
720 0 ▶ return if ! @{ $t };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$t;} 0 0 0
721 0 my($mname, $mversion, @rest) = split RE_CHAR_SLASH_WS, $moz;
722 0 ▶ return if $mname eq 'Mozilla' || $mname eq 'Emacs-W3';
Branch: 1 branch
BranchTrueFalseTotal
if $mname eq "Mozilla" or $mname eq "Emacs-W3" 0 0 0
Condition0%0/3
$mname eq "Mozilla" or $mname eq "Emacs-W3"
l!l&&r!l&&!r
000
MC/DC0%0/2
$mname eq "Mozilla" or $mname eq "Emacs-W3"
$mname eq "Mozilla" $mname eq "Emacs-W3"
Truth table0%0/3
A or B
A= $mname eq "Mozilla"B= $mname eq "Emacs-W3"
ABresult
1X1
011
000
723  
724 0 ▶ if ( index( $mname, 'Nokia' ) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($mname, "Nokia") != -1) 0 0 0
725 0 my($device, $num, $os, $series, @junk) = split m{[\s]+}xms,
726 $self->[UA_STRING_ORIGINAL];
727 0 ▶ if ( $device
Branch: 1 branch
BranchTrueFalseTotal
if ($device and $num and $os and $series and index($os, "SymbianOS") != -1) 0 0 0
Condition0%0/12
$device and $num and $os and $series and index($os, "SymbianOS") != -1
!ll&&!rl&&r
000
$device and $num and $os and $series
!ll&&!rl&&r
000
$device and $num and $os
!ll&&!rl&&r
000
$device and $num
!ll&&!rl&&r
000
MC/DC0%0/5
$device and $num and $os and $series and index($os, "SymbianOS") != -1
$device $num $os $series index($os, "SymbianOS") != -1
Truth table0%0/6
A and B and C and D and E
A= $deviceB= $numC= $osD= $seriesE= index($os, "SymbianOS") != -1
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
728 && $num
729 && $os
730 && $series
731 && index( $os, 'SymbianOS' ) != NO_IMATCH
732 ) {
733 0 return $self->_parse_symbian(
734 join ';', $os, "$series $device", join(q{ }, @junk, $num)
735 );
736 }
737 }
738  
739 0 $self->[UA_NAME] = $mname;
740 0 ▶ $self->[UA_VERSION_RAW] = $mversion || ( $mname eq 'Links' ? shift @{$t} : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$mname eq 'Links' ? : 0 0 0
Condition0%0/3
$mversion || ($mname eq 'Links' ? shift @{$t;} : 0)
l!l&&r!l&&!r
000
MC/DC0%0/2
$mversion || ($mname eq 'Links' ? shift @{$t;} : 0)
$mversion ($mname eq 'Links' ? shift @{$t;} : 0)
Truth table0%0/3
A || B
A= $mversionB= ($mname eq 'Links' ? shift @{$t;} : 0)
ABresult
1X1
011
000
741 $self->[UA_OS] = @rest ? join(q{ }, @rest)
742 0 ▶ : $t->[0] && $t->[0] !~ RE_DIGIT_DOT_DIGIT ? shift @{$t}
Branch: 2 branches
BranchTrueFalseTotal
@rest ? : 0 0 0
$t->[0] && !($t->[0] =~ / \d+ [.]? \d /msx) ? : 0 0 0
Condition0%0/3
$t->[0] and not $t->[0] =~ / \d+ [.]? \d /msx
!ll&&!rl&&r
000
MC/DC0%0/2
$t->[0] and not $t->[0] =~ / \d+ [.]? \d /msx
$t->[0] not $t->[0] =~ / \d+ [.]? \d /msx
Truth table0%0/3
A and not(B)
A= $t->[0]B= not $t->[0] =~ / \d+ [.]? \d /msx
ABresult
0X0
100
111
743 : undef;
744 0 ▶ my @extras = (@{$t}, $extra ? @{$extra} : (), @others );
Branch: 1 branch
BranchTrueFalseTotal
$extra ? : 0 0 0
745  
746 0 $self->_fix_generic(
747 \$self->[UA_OS], \$self->[UA_NAME], \$self->[UA_VERSION_RAW], \@extras
748 );
749  
750 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
751 0 $self->[UA_GENERIC] = 1;
752 0 $self->[UA_PARSER] = 'generic_moz_thing';
753  
754 0 return 1;
755 }
756  
757 0 ▶sub _generic_name_version {
Subroutine _generic_name_version: not called CC=9 SCAR=45.0
758 0 my($self, $moz, $thing, $extra, $compatible, @others) = @_;
759 0 ▶ my $ok = $moz && ! @{$thing} && ! $extra && ! $compatible && ! @others;
Condition0%0/12
$moz && !@{$thing;} && !$extra && !$compatible && !@others
!ll&&!rl&&r
000
$moz and not @{$thing;} and not $extra and not $compatible
!ll&&!rl&&r
000
$moz and not @{$thing;} and not $extra
!ll&&!rl&&r
000
$moz and not @{$thing;}
!ll&&!rl&&r
000
MC/DC0%0/5
$moz && !@{$thing;} && !$extra && !$compatible && !@others
$moz not @{$thing;} not $extra not $compatible !@others
Truth table0%0/6
A and not(B) and not(C) and not(D) && not(E)
A= $mozB= not @{$thing;}C= not $extraD= not $compatibleE= !@others
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
760 0 ▶ return if not $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
761  
762 0 my @moz = split RE_WHITESPACE, $moz;
763 0 ▶ if ( @moz == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@moz == 1) 0 0 0
764 0 my($name, $version) = split RE_SLASH, $moz;
765 0 ▶ if ($name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $version) 0 0 0
Condition0%0/3
$name and $version
!ll&&!rl&&r
000
MC/DC0%0/2
$name and $version
$name $version
Truth table0%0/3
A and B
A= $nameB= $version
ABresult
0X0
100
111
766 0 $self->[UA_NAME] = $name;
767 0 $self->[UA_VERSION_RAW] = $version;
768 0 $self->[UA_GENERIC] = 1;
769 0 $self->[UA_PARSER] = 'generic_name_version';
770 0 return 1;
771 }
772 }
773 0 return;
774 }
775  
776 0 ▶sub _generic_compatible {
Subroutine _generic_compatible: not called CC=18 SCAR=58.3
777 0 my($self, $moz, $thing, $extra, $compatible, @others) = @_;
778 0 my @orig_thing = @{ $thing }; # see edge case below
779  
780 0 ▶ return if ! ( $compatible && @{$thing} );
Branch: 1 branch
BranchTrueFalseTotal
unless $compatible and @{$thing;} 0 0 0
Condition0%0/3
$compatible and @{$thing;}
!ll&&!rl&&r
000
MC/DC0%0/2
$compatible and @{$thing;}
$compatible @{$thing;}
Truth table0%0/3
A and B
A= $compatibleB= @{$thing;}
ABresult
0X0
100
111
781  
782 0 my($mname, $mversion) = split RE_CHAR_SLASH_WS, $moz;
783 my($name, $version) = $mname eq 'Mozilla'
784 0 ▶ ? split( RE_CHAR_SLASH_WS, shift @{ $thing } )
Branch: 1 branch
BranchTrueFalseTotal
$mname eq 'Mozilla' ? : 0 0 0
785 : ($mname, $mversion)
786 ;
787 0 ▶ shift @{$thing} if $thing->[0] &&
Branch: 1 branch
BranchTrueFalseTotal
if $thing->[0] and $thing->[0] eq $name || $thing->[0] eq $moz 0 0 0
Condition0%0/6
$thing->[0] and $thing->[0] eq $name || $thing->[0] eq $moz
!ll&&!rl&&r
000
$thing->[0] eq $name or $thing->[0] eq $moz
l!l&&r!l&&!r
000
MC/DC0%0/3
$thing->[0] and $thing->[0] eq $name || $thing->[0] eq $moz
$thing->[0] $thing->[0] eq $name $thing->[0] eq $moz
Truth table0%0/4
A and B or C
A= $thing->[0]B= $thing->[0] eq $nameC= $thing->[0] eq $moz
ABCresult
0XX0
1000
11X1
1011
788 ( $thing->[0] eq $name || $thing->[0] eq $moz);
789 0 my $os = shift @{$thing};
790 0 my $lang = pop @{$thing};
791 0 my @extras;
792  
793 0 ▶ if ( $name eq 'MSIE') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "MSIE") 0 0 0
794 0 ▶ if ( $self->_is_generic_bogus_ie( $extra ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_is_generic_bogus_ie($extra)) { } 0 0 0
elsif ($extra) { } 0 0 0
795 # edge case
796 0 my($n, $v) = split RE_WHITESPACE, shift @orig_thing;
797 0 my $e = [ split RE_SC_WS, join q{ }, @{ $extra } ];
798 0 my $t = \@orig_thing;
799 0 push @{ $e }, grep { $_ } map { split RE_SC_WS, $_ } @others;
800 0 $self->_parse_msie( $moz, $thing, $e, $n, $v );
801 0 return 1;
802 }
803 elsif ( $extra ) { # Sleipnir?
804 0 ($name, $version) = split RE_SLASH, pop @{$extra};
805 0 my($extras,$dotnet) = $self->_extract_dotnet( $thing, $extra );
806 0 ▶ $self->[UA_DOTNET] = [ @{$dotnet} ] if @{$dotnet};
Branch: 1 branch
BranchTrueFalseTotal
if @{$dotnet;} 0 0 0
807 0 @extras = (@{ $extras }, @others);
808 }
809 else {
810 0 ▶ return if index($moz, q{ }) != NO_IMATCH; # WebTV
Branch: 1 branch
BranchTrueFalseTotal
if index($moz, " ") != -1 0 0 0
811 }
812 }
813  
814 0 ▶ @extras = (@{$thing}, $extra ? @{$extra} : (), @others ) if ! @extras;
Branch: 2 branches
BranchTrueFalseTotal
unless @extras 0 0 0
$extra ? : 0 0 0
815  
816 0 ▶ if ( $lang && index( $lang, 'MSIE ') != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lang and index($lang, "MSIE ") != -1) 0 0 0
Condition0%0/3
$lang and index($lang, "MSIE ") != -1
!ll&&!rl&&r
000
MC/DC0%0/2
$lang and index($lang, "MSIE ") != -1
$lang index($lang, "MSIE ") != -1
Truth table0%0/3
A and B
A= $langB= index($lang, "MSIE ") != -1
ABresult
0X0
100
111
817 0 return $self->_parse_msie(
818 $moz,
819 [],
820 [$os, "$name/$version", @extras], # junk
821 split( m{[\s]+}xms, $lang, 2 ), # name, version
822 );
823 }
824  
825 0 $self->_fix_generic( \$os, \$name, \$version, \@extras );
826  
827 0 $self->[UA_NAME] = $name;
828 0 ▶ $self->[UA_VERSION_RAW] = $version || 0;
Condition0%0/2
$version || 0
l!l
00
MC/DC0%0/1
$version || 0
$version
Truth table0%0/2
A
A= $version
Aresult
11
00
829 0 $self->[UA_OS] = $os;
830 0 $self->[UA_LANG] = $lang;
831 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
832 0 $self->[UA_GENERIC] = 1;
833 0 $self->[UA_PARSER] = 'generic_compatible';
834  
835 0 return 1;
836 }
837  
838 0 ▶sub _parse_emacs {
Subroutine _parse_emacs: not called CC=7 SCAR=40.3
839 0 my($self, $moz, $thing, $extra, $compatible, @others) = @_;
840 0 my @moz = split RE_WHITESPACE, $moz;
841 0 my $emacs = shift @moz;
842 0 my($name, $version) = split RE_SLASH, $emacs;
843 0 $self->[UA_NAME] = $name;
844 0 ▶ $self->[UA_VERSION_RAW] = $version || 0;
Condition0%0/2
$version || 0
l!l
00
MC/DC0%0/1
$version || 0
$version
Truth table0%0/2
A
A= $version
Aresult
11
00
845 0 $self->[UA_OS] = shift @{ $thing };
846 0 ▶ $self->[UA_OS] = $self->trim( $self->[UA_OS] ) if $self->[UA_OS];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[26] 0 0 0
847 0 my @rest = ( @{ $thing }, @moz );
848 0 ▶ push @rest, @{ $extra } if $extra && ref $extra eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $extra and ref $extra eq "ARRAY" 0 0 0
Condition0%0/3
$extra and ref $extra eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$extra and ref $extra eq "ARRAY"
$extra ref $extra eq "ARRAY"
Truth table0%0/3
A and B
A= $extraB= ref $extra eq "ARRAY"
ABresult
0X0
100
111
849 0 ▶ push @rest, ( map { split RE_SC_WS, $_ } @others ) if @others;
Branch: 1 branch
BranchTrueFalseTotal
if @others 0 0 0
850 0 my @extras = grep { $_ } map { $self->trim( $_ ) } @rest;
851 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
852 0 $self->[UA_PARSER] = 'emacs';
853 0 return 1;
854 }
855  
856 0 ▶sub _parse_moz_only {
Subroutine _parse_moz_only: not called CC=9 SCAR=45.0
857 0 my $self = shift;
858 0 my($moz) = @_;
859 0 my @parts = split RE_WHITESPACE, $moz;
860 0 my $id = shift @parts;
861 0 my($name, $version) = split RE_SLASH, $id;
862  
863 0 ▶ if ( index( $name, 'Symbian' ) != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($name, "Symbian") != -1) 0 0 0
864 0 return $self->_parse_symbian( $moz );
865 }
866  
867 0 ▶ if ( $name eq 'Mozilla' && @parts ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "Mozilla" and @parts) 0 0 0
Condition0%0/3
$name eq "Mozilla" and @parts
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "Mozilla" and @parts
$name eq "Mozilla" @parts
Truth table0%0/3
A and B
A= $name eq "Mozilla"B= @parts
ABresult
0X0
100
111
868 0 ($name, $version) = split RE_SLASH, shift @parts;
869 0 ▶ return if ! $name || ! $version;
Branch: 1 branch
BranchTrueFalseTotal
unless $name and $version 0 0 0
Condition0%0/3
$name and $version
!ll&&!rl&&r
000
MC/DC0%0/2
$name and $version
$name $version
Truth table0%0/3
A and B
A= $nameB= $version
ABresult
0X0
100
111
870 }
871  
872 0 $self->[UA_NAME] = $name;
873 0 ▶ $self->[UA_VERSION_RAW] = $version || 0;
Condition0%0/2
$version || 0
l!l
00
MC/DC0%0/1
$version || 0
$version
Truth table0%0/2
A
A= $version
Aresult
11
00
874 0 ▶ $self->[UA_EXTRAS] = @parts ? [ @parts ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@parts ? : 0 0 0
875 0 $self->[UA_PARSER] = 'moz_only';
876 0 ▶ $self->[UA_ROBOT] = 1 if ! $self->[UA_VERSION_RAW];
Branch: 1 branch
BranchTrueFalseTotal
unless $self->[26] 0 0 0
877  
878 0 return 1;
879 }
880  
881 0 ▶sub _parse_symbian {
Subroutine _parse_symbian: not called CC=5 SCAR=34.0
882 0 my($self, $raw) = @_;
883 0 my($os, $series_device, @rest) = split m{[;]\s?}xms, $raw;
884  
885 0 ▶ return if ! $os || ! $series_device;
Branch: 1 branch
BranchTrueFalseTotal
unless $os and $series_device 0 0 0
Condition0%0/3
$os and $series_device
!ll&&!rl&&r
000
MC/DC0%0/2
$os and $series_device
$os $series_device
Truth table0%0/3
A and B
A= $osB= $series_device
ABresult
0X0
100
111
886  
887 0 my($series, $device) = split m{[\s]+}xms, $series_device;
888  
889 0 ▶ return if ! $device;
Branch: 1 branch
BranchTrueFalseTotal
unless $device 0 0 0
890  
891 0 my @extras = map { split m{[\s]+}xms, $_ } @rest;
892  
893 0 @{ $self }[ UA_NAME, UA_VERSION_RAW ] = split RE_SLASH, $series, 2;
894 0 $self->[UA_OS] = $os;
895 0 $self->[UA_DEVICE] = $device;
896 0 ▶ $self->[UA_EXTRAS] = @extras ? [ @extras ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@extras ? : 0 0 0
897 0 $self->[UA_MOBILE] = 1;
898 0 $self->[UA_PARSER] = 'symbian';
899  
900 0 return 1;
901 }
902  
903 0 ▶sub _parse_hotjava {
Subroutine _parse_hotjava: not called CC=5 SCAR=34.0
904 0 my($self, $moz, $thing, $extra, $compatible, @others) = @_;
905 0 my $parsable = shift @{ $thing };
906 0 my($name, $version) = split RE_SLASH, $moz;
907 0 $self->[UA_NAME] = 'HotJava';
908 0 ▶ $self->[UA_VERSION_RAW] = $version || 0;
Condition0%0/2
$version || 0
l!l
00
MC/DC0%0/1
$version || 0
$version
Truth table0%0/2
A
A= $version
Aresult
11
00
909 0 ▶ if ( $parsable ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsable) 0 0 0
910 0 my @parts = split m{[\[\]]}xms, $parsable;
911 0 ▶ if ( @parts > 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@parts > 2) 0 0 0
912 0 @parts = map { $self->trim( $_ ) } @parts;
913 0 $self->[UA_OS] = pop @parts;
914 0 $self->[UA_LANG] = pop @parts;
915 0 ▶ $self->[UA_EXTRAS] = @parts ? [ @parts ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@parts ? : 0 0 0
916 }
917 }
918 0 return 1;
919 }
920  
921 0 ▶sub _parse_docomo {
Subroutine _parse_docomo: not called CC=4 SCAR=30.0
922 0 my($self, $moz, $thing, $extra, $compatible, @others) = @_;
923 0 ▶ if ( $thing->[0] && index(lc $thing->[0], 'googlebot-mobile') != NO_IMATCH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thing->[0] and index(lc $thing->[0], "googlebot-mobile") != -1) 0 0 0
Condition0%0/3
$thing->[0] and index(lc $thing->[0], "googlebot-mobile") != -1
!ll&&!rl&&r
000
MC/DC0%0/2
$thing->[0] and index(lc $thing->[0], "googlebot-mobile") != -1
$thing->[0] index(lc $thing->[0], "googlebot-mobile") != -1
Truth table0%0/3
A and B
A= $thing->[0]B= index(lc $thing->[0], "googlebot-mobile") != -1
ABresult
0X0
100
111
924 0 my($name, $version) = split RE_SLASH, shift @{ $thing };
925 0 $self->[UA_NAME] = $name;
926 0 $self->[UA_VERSION_RAW] = $version;
927 0 ▶ $self->[UA_EXTRAS] = @{ $thing } > 0 ? [ @{ $thing } ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@{$thing;} > 0 ? : 0 0 0
928 0 $self->[UA_MOBILE] = 1;
929 0 $self->[UA_ROBOT] = 1;
930 0 $self->[UA_PARSER] = 'docomo';
931 0 return 1;
932 }
933 #$self->[UA_PARSER] = 'docomo';
934 #require Data::Dumper;warn "DoCoMo unsupported: ".Data::Dumper::Dumper( [ $moz, $thing, $extra, $compatible, \@others ] );
935 0 return;
936 }
937  
938 4 1;
939  
940 __END__
« UserAgent.pm ↑ Summary UserAgent/Base/Dumper.pm »