line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::HTTP::UserAgent::Constants; |
2
|
|
|
|
|
|
|
$Parse::HTTP::UserAgent::Constants::VERSION = '0.41'; |
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
47
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
43
|
|
5
|
2
|
|
|
2
|
|
8
|
use base qw( Exporter ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
258
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
|
|
963
|
use constant LIST_ROBOTS => qw( |
10
|
|
|
|
|
|
|
Wget |
11
|
|
|
|
|
|
|
curl |
12
|
|
|
|
|
|
|
libwww-perl |
13
|
|
|
|
|
|
|
GetRight |
14
|
|
|
|
|
|
|
Googlebot |
15
|
|
|
|
|
|
|
Baiduspider+ |
16
|
|
|
|
|
|
|
msnbot |
17
|
|
|
|
|
|
|
bingbot |
18
|
2
|
|
|
2
|
|
10
|
), 'Yahoo! Slurp'; |
|
2
|
|
|
|
|
4
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
BEGIN { |
21
|
2
|
|
|
2
|
|
12
|
my @fields = ( |
22
|
|
|
|
|
|
|
'IS_EXTENDED', |
23
|
|
|
|
|
|
|
'IS_MAXTHON', # Is this the dumb IE faker? |
24
|
|
|
|
|
|
|
'IS_PARSED', # _parse() happened or not |
25
|
|
|
|
|
|
|
'IS_TRIDENT', # Thanks to Microsoft, this now has a meaning |
26
|
|
|
|
|
|
|
'UA_DEVICE', # the name of the mobile device |
27
|
|
|
|
|
|
|
'UA_DOTNET', # [MSIE] List of .NET CLR versions |
28
|
|
|
|
|
|
|
'UA_EXTRAS', # Extra stuff (Toolbars?) non parsable junk |
29
|
|
|
|
|
|
|
'UA_GENERIC', # parsed with a generic parser. |
30
|
|
|
|
|
|
|
'UA_LANG', # the language of the ua interface |
31
|
|
|
|
|
|
|
'UA_MOBILE', # partially implemented |
32
|
|
|
|
|
|
|
'UA_MOZILLA', # [Firefox] Mozilla revision |
33
|
|
|
|
|
|
|
'UA_NAME', # The identifier of the ua |
34
|
|
|
|
|
|
|
'UA_ORIGINAL_NAME', # original name if this is some variation |
35
|
|
|
|
|
|
|
'UA_ORIGINAL_VERSION', # original version if this is some variation |
36
|
|
|
|
|
|
|
'UA_OS', # Operating system |
37
|
|
|
|
|
|
|
'UA_PARSER', # the parser name |
38
|
|
|
|
|
|
|
'UA_ROBOT', # Is this a robot? |
39
|
|
|
|
|
|
|
'UA_STRENGTH', # [MSIE] List of .NET CLR versions |
40
|
|
|
|
|
|
|
'UA_STRING', # just for information |
41
|
|
|
|
|
|
|
'UA_STRING_ORIGINAL', # just for information |
42
|
|
|
|
|
|
|
'UA_TABLET', # partially implemented |
43
|
|
|
|
|
|
|
'UA_TOOLKIT', # [Opera] ua toolkit |
44
|
|
|
|
|
|
|
'UA_TOUCH', # windows only? |
45
|
|
|
|
|
|
|
'UA_UNKNOWN', # failed to detect? |
46
|
|
|
|
|
|
|
'UA_VERSION', # used for numerical ops. via qv() |
47
|
|
|
|
|
|
|
'UA_VERSION_RAW', # the parsed version |
48
|
|
|
|
|
|
|
'UA_WAP', # unimplemented |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
3
|
my $oid = -1; |
52
|
2
|
|
|
|
|
4
|
my %field = map { $_ => ++$oid } @fields; |
|
54
|
|
|
|
|
95
|
|
53
|
2
|
|
|
|
|
700
|
my %const = ( |
54
|
|
|
|
|
|
|
%field, |
55
|
|
|
|
|
|
|
LAST_ELEMENT => -1, |
56
|
|
|
|
|
|
|
MAXID => $oid, |
57
|
|
|
|
|
|
|
NO_IMATCH => -1, # for index() |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
RE_CHAR_SLASH_WS => qr{ [/\s] }xms, |
60
|
|
|
|
|
|
|
RE_COMMA => qr{ [,] }xms, |
61
|
|
|
|
|
|
|
RE_DIGIT => qr{ [0-9] }xms, |
62
|
|
|
|
|
|
|
RE_DIGIT_DOT_DIGIT => qr{ \d+ [.]? \d }xms, |
63
|
|
|
|
|
|
|
RE_DOTNET => qr{ \A [.]NET (?: \s+ CLR \s+ )? (.+?) \z }xms, |
64
|
|
|
|
|
|
|
RE_EPIPHANY_GECKO => qr{ \A (Epiphany) / (.+?) \z }xmsi, |
65
|
|
|
|
|
|
|
RE_FIREFOX_NAMES => qr{ Firefox|Iceweasel|Firebird|Phoenix }xms, |
66
|
|
|
|
|
|
|
RE_HTTP => qr{ http:// }xms, |
67
|
|
|
|
|
|
|
RE_IX86 => qr{ \s i\d86 }xms, |
68
|
|
|
|
|
|
|
RE_OBJECT_ID => qr{ \A UA_ }xms, |
69
|
|
|
|
|
|
|
RE_OPERA_MINI => qr{ \A (Opera \s+ Mini) / (.+?) \z }xms, |
70
|
|
|
|
|
|
|
RE_SC_WS => qr{ ; \s? }xms, |
71
|
|
|
|
|
|
|
RE_SC_WS_MULTI => qr{ ; \s+? }xms, |
72
|
|
|
|
|
|
|
RE_SLASH => qr{ / }xms, |
73
|
|
|
|
|
|
|
RE_SPLIT_PARSE => qr{ \s? ([()]) \s? }xms, |
74
|
|
|
|
|
|
|
RE_TWO_LETTER_LANG => qr{ \A [a-z]{2} \z }xms, |
75
|
|
|
|
|
|
|
RE_WARN_INVALID => qr{ \QVersion string\E .+? \Qcontains invalid data; ignoring:\E}xms, |
76
|
|
|
|
|
|
|
RE_WARN_OVERFLOW => qr{ \QInteger overflow in version\E }xms, |
77
|
|
|
|
|
|
|
RE_WHITESPACE => qr{ \s+ }xms, |
78
|
|
|
|
|
|
|
RE_WINDOWS_OS => qr{ \A Win(dows|NT|[0-9]+)? }xmsi, |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
ERROR_MAXTHON_MSIE => 'Unable to extract MSIE from Maxthon UA-string', |
81
|
|
|
|
|
|
|
ERROR_MAXTHON_VERSION => 'Unable to extract Maxthon version from Maxthon UA-string', |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
OPERA9 => 9, |
84
|
|
|
|
|
|
|
OPERA_FAKER_EXTRA_SIZE => 4, |
85
|
|
|
|
|
|
|
OPERA_TK_LENGTH => 5, |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
TK_NAME => 0, |
88
|
|
|
|
|
|
|
TK_ORIGINAL_VERSION => 1, |
89
|
|
|
|
|
|
|
TK_VERSION => 2, |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
2
|
50
|
|
|
|
15
|
$const{INSIDE_UNIT_TEST} = $ENV{PARSE_HTTP_USERAGENT_TEST_SUITE} ? 1 : 0; |
93
|
|
|
|
|
|
|
$const{INSIDE_VERBOSE_TEST} = $const{INSIDE_UNIT_TEST} |
94
|
2
|
50
|
33
|
|
|
15
|
&& $ENV{HARNESS_IS_VERBOSE} ? 1 : 0; |
95
|
|
|
|
|
|
|
|
96
|
2
|
|
|
|
|
9
|
require constant; |
97
|
2
|
|
|
|
|
951
|
constant->import( \%const ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
BEGIN { |
101
|
2
|
|
|
2
|
|
20
|
%EXPORT_TAGS = ( |
102
|
|
|
|
|
|
|
object_ids => [qw( |
103
|
|
|
|
|
|
|
IS_PARSED |
104
|
|
|
|
|
|
|
IS_MAXTHON |
105
|
|
|
|
|
|
|
IS_TRIDENT |
106
|
|
|
|
|
|
|
IS_EXTENDED |
107
|
|
|
|
|
|
|
UA_STRING |
108
|
|
|
|
|
|
|
UA_STRING_ORIGINAL |
109
|
|
|
|
|
|
|
UA_UNKNOWN |
110
|
|
|
|
|
|
|
UA_GENERIC |
111
|
|
|
|
|
|
|
UA_NAME |
112
|
|
|
|
|
|
|
UA_VERSION_RAW |
113
|
|
|
|
|
|
|
UA_VERSION |
114
|
|
|
|
|
|
|
UA_OS |
115
|
|
|
|
|
|
|
UA_LANG |
116
|
|
|
|
|
|
|
UA_TOOLKIT |
117
|
|
|
|
|
|
|
UA_EXTRAS |
118
|
|
|
|
|
|
|
UA_DOTNET |
119
|
|
|
|
|
|
|
UA_MOZILLA |
120
|
|
|
|
|
|
|
UA_STRENGTH |
121
|
|
|
|
|
|
|
UA_ROBOT |
122
|
|
|
|
|
|
|
UA_WAP |
123
|
|
|
|
|
|
|
UA_MOBILE |
124
|
|
|
|
|
|
|
UA_TABLET |
125
|
|
|
|
|
|
|
UA_TOUCH |
126
|
|
|
|
|
|
|
UA_PARSER |
127
|
|
|
|
|
|
|
UA_DEVICE |
128
|
|
|
|
|
|
|
UA_ORIGINAL_NAME |
129
|
|
|
|
|
|
|
UA_ORIGINAL_VERSION |
130
|
|
|
|
|
|
|
MAXID |
131
|
|
|
|
|
|
|
)], |
132
|
|
|
|
|
|
|
re => [qw( |
133
|
|
|
|
|
|
|
RE_FIREFOX_NAMES |
134
|
|
|
|
|
|
|
RE_DOTNET |
135
|
|
|
|
|
|
|
RE_WINDOWS_OS |
136
|
|
|
|
|
|
|
RE_SLASH |
137
|
|
|
|
|
|
|
RE_SPLIT_PARSE |
138
|
|
|
|
|
|
|
RE_OPERA_MINI |
139
|
|
|
|
|
|
|
RE_EPIPHANY_GECKO |
140
|
|
|
|
|
|
|
RE_WHITESPACE |
141
|
|
|
|
|
|
|
RE_SC_WS |
142
|
|
|
|
|
|
|
RE_SC_WS_MULTI |
143
|
|
|
|
|
|
|
RE_HTTP |
144
|
|
|
|
|
|
|
RE_DIGIT |
145
|
|
|
|
|
|
|
RE_IX86 |
146
|
|
|
|
|
|
|
RE_OBJECT_ID |
147
|
|
|
|
|
|
|
RE_CHAR_SLASH_WS |
148
|
|
|
|
|
|
|
RE_COMMA |
149
|
|
|
|
|
|
|
RE_TWO_LETTER_LANG |
150
|
|
|
|
|
|
|
RE_DIGIT_DOT_DIGIT |
151
|
|
|
|
|
|
|
RE_WARN_OVERFLOW |
152
|
|
|
|
|
|
|
RE_WARN_INVALID |
153
|
|
|
|
|
|
|
)], |
154
|
|
|
|
|
|
|
list => [qw( |
155
|
|
|
|
|
|
|
LIST_ROBOTS |
156
|
|
|
|
|
|
|
)], |
157
|
|
|
|
|
|
|
tk => [qw( |
158
|
|
|
|
|
|
|
TK_NAME |
159
|
|
|
|
|
|
|
TK_ORIGINAL_VERSION |
160
|
|
|
|
|
|
|
TK_VERSION |
161
|
|
|
|
|
|
|
)], |
162
|
|
|
|
|
|
|
etc => [qw( |
163
|
|
|
|
|
|
|
NO_IMATCH |
164
|
|
|
|
|
|
|
LAST_ELEMENT |
165
|
|
|
|
|
|
|
INSIDE_UNIT_TEST |
166
|
|
|
|
|
|
|
INSIDE_VERBOSE_TEST |
167
|
|
|
|
|
|
|
)], |
168
|
|
|
|
|
|
|
error => [qw( |
169
|
|
|
|
|
|
|
ERROR_MAXTHON_VERSION |
170
|
|
|
|
|
|
|
ERROR_MAXTHON_MSIE |
171
|
|
|
|
|
|
|
)], |
172
|
|
|
|
|
|
|
opera => [qw( |
173
|
|
|
|
|
|
|
OPERA9 |
174
|
|
|
|
|
|
|
OPERA_TK_LENGTH |
175
|
|
|
|
|
|
|
OPERA_FAKER_EXTRA_SIZE |
176
|
|
|
|
|
|
|
)], |
177
|
|
|
|
|
|
|
); |
178
|
|
|
|
|
|
|
|
179
|
2
|
|
|
|
|
6
|
@EXPORT_OK = map { @{ $_ } } values %EXPORT_TAGS; |
|
14
|
|
|
|
|
18
|
|
|
14
|
|
|
|
|
32
|
|
180
|
2
|
|
|
|
|
55
|
$EXPORT_TAGS{all} = [ @EXPORT_OK ]; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
1; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
__END__ |