line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::HTTP::UserAgent::Base::IS; |
2
|
|
|
|
|
|
|
$Parse::HTTP::UserAgent::Base::IS::VERSION = '0.41'; |
3
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
54
|
|
5
|
2
|
|
|
2
|
|
551
|
use Parse::HTTP::UserAgent::Constants qw(:all); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2213
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub _is_opera_pre { |
8
|
384
|
|
|
384
|
|
667
|
my($self, $moz) = @_; |
9
|
384
|
|
|
|
|
1461
|
return index( $moz, 'Opera') != NO_IMATCH; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _is_opera_post { |
13
|
350
|
|
|
350
|
|
603
|
my($self, $extra) = @_; |
14
|
350
|
|
100
|
|
|
1457
|
return $extra && $extra->[0] eq 'Opera'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _is_opera_ff { # opera faking as firefox |
18
|
336
|
|
|
336
|
|
517
|
my($self, $extra) = @_; |
19
|
|
|
|
|
|
|
return $extra |
20
|
336
|
|
100
|
|
|
800
|
&& @{$extra} == OPERA_FAKER_EXTRA_SIZE |
21
|
|
|
|
|
|
|
&& $extra->[2] eq 'Opera'; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _is_safari { |
25
|
286
|
|
|
286
|
|
510
|
my($self, $extra, $others) = @_; |
26
|
286
|
|
|
|
|
393
|
my $str = $self->[UA_STRING]; |
27
|
|
|
|
|
|
|
# epiphany? |
28
|
|
|
|
|
|
|
return index( $str , 'Chrome' ) != NO_IMATCH ? 0 # faker |
29
|
|
|
|
|
|
|
: index( $str , 'Android' ) != NO_IMATCH ? 0 # faker |
30
|
|
|
|
|
|
|
: $extra && index( $extra->[0] , 'AppleWebKit' ) != NO_IMATCH ? 1 |
31
|
286
|
50
|
100
|
|
|
1158
|
: @{$others} && index( $others->[LAST_ELEMENT], 'Safari' ) != NO_IMATCH ? 1 |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
|
|
|
|
|
|
: 0 |
33
|
|
|
|
|
|
|
; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _is_chrome { |
37
|
250
|
|
|
250
|
|
418
|
my($self, $extra, $others) = @_; |
38
|
250
|
|
100
|
|
|
825
|
my $chx = $others->[1] || return; |
39
|
64
|
|
|
|
|
244
|
my($chrome, $safari) = split RE_WHITESPACE, $chx; |
40
|
64
|
100
|
66
|
|
|
260
|
return if ! ( $chrome && $safari); |
41
|
|
|
|
|
|
|
|
42
|
60
|
|
66
|
|
|
348
|
return index( $chrome , 'Chrome' ) != NO_IMATCH && |
43
|
|
|
|
|
|
|
index( $safari , 'Safari' ) != NO_IMATCH && |
44
|
|
|
|
|
|
|
( $extra && index( $extra->[0], 'AppleWebKit') != NO_IMATCH); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _is_android { |
48
|
230
|
|
|
230
|
|
367
|
my($self, $thing, $others) = @_; |
49
|
230
|
|
|
|
|
278
|
my $has_android = grep { index( lc $_, 'android' ) != NO_IMATCH } @{ $thing }; |
|
690
|
|
|
|
|
1384
|
|
|
230
|
|
|
|
|
412
|
|
50
|
230
|
|
|
|
|
307
|
my $has_safari = grep { index( lc $_, 'safari' ) != NO_IMATCH } @{ $others }; |
|
126
|
|
|
|
|
241
|
|
|
230
|
|
|
|
|
354
|
|
51
|
230
|
100
|
100
|
|
|
542
|
if ( $has_android && $has_safari ) { |
52
|
40
|
|
|
|
|
133
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
190
|
100
|
100
|
|
|
243
|
if ( @{ $others } == 0 |
|
190
|
|
66
|
|
|
404
|
|
|
|
|
66
|
|
|
|
|
55
|
164
|
|
|
|
|
731
|
&& @{ $thing } > 0 |
56
|
|
|
|
|
|
|
&& $thing->[-1] |
57
|
|
|
|
|
|
|
&& index( $thing->[-1], 'AppleWebKit' ) != NO_IMATCH |
58
|
|
|
|
|
|
|
) { |
59
|
|
|
|
|
|
|
# More stupidity: ua string is missing a closing paren |
60
|
2
|
|
|
|
|
13
|
my($part, @rest) = split m{(AppleWebKit)}xms, $thing->[-1]; |
61
|
2
|
|
|
|
|
4
|
$thing->[-1] = $part; |
62
|
2
|
|
|
|
|
12
|
@{ $others } = map { $self->trim( $_ ) } |
|
2
|
|
|
|
|
4
|
|
|
6
|
|
|
|
|
15
|
|
63
|
|
|
|
|
|
|
split m{ (\QKHTML, like Gecko\E) }xms, |
64
|
|
|
|
|
|
|
join q{}, @rest; |
65
|
2
|
|
|
|
|
9
|
return 1; |
66
|
|
|
|
|
|
|
} |
67
|
188
|
|
|
|
|
585
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _is_ff { |
71
|
334
|
|
|
334
|
|
537
|
my($self, $extra) = @_; |
72
|
334
|
100
|
100
|
|
|
1359
|
return if ! $extra || ! $extra->[1]; |
73
|
82
|
|
66
|
|
|
181
|
my $moz_with_name = $extra->[1] eq 'Mozilla' && $extra->[2]; |
74
|
|
|
|
|
|
|
return $moz_with_name |
75
|
82
|
100
|
33
|
|
|
520
|
? $extra->[2] =~ RE_FIREFOX_NAMES && do { $extra->[1] = $extra->[2] } |
76
|
|
|
|
|
|
|
: $extra->[1] =~ RE_FIREFOX_NAMES |
77
|
|
|
|
|
|
|
; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _is_suspicious_ff { |
81
|
188
|
|
|
188
|
|
329
|
my($self, $extra) = @_; |
82
|
|
|
|
|
|
|
return if ref $extra ne 'ARRAY' |
83
|
188
|
100
|
100
|
|
|
538
|
|| @{ $extra } != 1 |
|
76
|
|
100
|
|
|
383
|
|
84
|
|
|
|
|
|
|
|| index( lc $extra->[0], 'firefox/' ) == NO_IMATCH; |
85
|
2
|
|
|
|
|
10
|
return 1; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _is_gecko { |
89
|
188
|
|
|
188
|
|
671
|
return index(shift->[UA_STRING], 'Gecko/') != NO_IMATCH; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _is_generic { #TODO: this is actually a parser |
93
|
110
|
|
|
110
|
|
228
|
my($self, @args) = @_; |
94
|
110
|
100
|
100
|
|
|
286
|
return 1 if $self->_generic_name_version( @args ) || |
|
|
|
100
|
|
|
|
|
95
|
|
|
|
|
|
|
$self->_generic_compatible( @args ) || |
96
|
|
|
|
|
|
|
$self->_generic_moz_thing( @args ); |
97
|
26
|
|
|
|
|
68
|
return; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _is_netscape { |
101
|
138
|
|
|
138
|
|
295
|
my($self, $moz, $thing, $extra, $compatible, @others) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $rv = index($moz, 'Mozilla/') != NO_IMATCH && |
104
|
|
|
|
|
|
|
$moz ne 'Mozilla/4.0' && |
105
|
|
|
|
|
|
|
! $compatible && |
106
|
|
|
|
|
|
|
! $extra && |
107
|
|
|
|
|
|
|
! @others && |
108
|
138
|
|
66
|
|
|
561
|
( @{$thing} && $thing->[LAST_ELEMENT] ne 'Sun' ) && # hotjava |
109
|
|
|
|
|
|
|
index($thing->[0], 'http://') == NO_IMATCH # robot |
110
|
|
|
|
|
|
|
; |
111
|
138
|
|
|
|
|
418
|
return $rv; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub _is_docomo { |
115
|
112
|
|
|
112
|
|
182
|
my($self, $moz) = @_; |
116
|
112
|
|
|
|
|
343
|
return index(lc $moz, 'docomo') != NO_IMATCH; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _is_strength { |
120
|
1120
|
|
|
1120
|
|
1474
|
my $self = shift; |
121
|
1120
|
|
100
|
|
|
1927
|
my $s = shift || return; |
122
|
1112
|
|
|
|
|
2308
|
$s = $self->trim( $s ); |
123
|
1112
|
100
|
100
|
|
|
4248
|
return $s if $s eq 'U' || $s eq 'I' || $s eq 'N'; |
|
|
|
66
|
|
|
|
|
124
|
934
|
|
|
|
|
1991
|
return; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub _is_emacs { |
128
|
26
|
|
|
26
|
|
47
|
my($self, $moz) = @_; |
129
|
26
|
|
|
|
|
103
|
return index( $moz, 'Emacs-W3/') != NO_IMATCH; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub _is_moz_only { |
133
|
22
|
|
|
22
|
|
49
|
my($self, $moz, $thing, $extra, $compatible, @others) = @_; |
134
|
22
|
|
66
|
|
|
49
|
return $moz && ! @{ $thing } && ! $extra && ! @others; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub _is_hotjava { |
138
|
2
|
|
|
2
|
|
6
|
my($self, $moz, $thing, $extra, $compatible, @others) = @_; |
139
|
2
|
|
|
|
|
5
|
my @hot = @{ $thing }; |
|
2
|
|
|
|
|
5
|
|
140
|
2
|
|
33
|
|
|
26
|
return @hot == 2 && $hot[1] eq 'Sun'; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub _is_generic_bogus_ie { |
144
|
4
|
|
|
4
|
|
11
|
my($self, $extra) = @_; |
145
|
4
|
|
0
|
|
|
45
|
my $rv = $extra |
146
|
|
|
|
|
|
|
&& $extra->[0] |
147
|
|
|
|
|
|
|
&& index( $extra->[0], 'compatible' ) != NO_IMATCH |
148
|
|
|
|
|
|
|
&& $extra->[1] |
149
|
|
|
|
|
|
|
&& $extra->[1] eq 'MSIE'; |
150
|
4
|
|
|
|
|
18
|
return $rv; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
1; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
__END__ |