File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,10 @@ class phpUserAgentStringParser
18
18
*/
19
19
public function parse ($ userAgentString = null )
20
20
{
21
- // use current user agetn string as default
21
+ // use current user agent string as default
22
22
if (!$ userAgentString )
23
23
{
24
- $ userAgentString = $ _SERVER ['HTTP_USER_AGENT ' ];
24
+ $ userAgentString = isset ( $ _SERVER ['HTTP_USER_AGENT ' ]) ? $ _SERVER [ ' HTTP_USER_AGENT ' ] : null ;
25
25
}
26
26
27
27
// parse quickly (with medium accuracy)
@@ -51,6 +51,11 @@ protected function doParse($userAgentString)
51
51
'operating_system ' => null
52
52
);
53
53
54
+ if (empty ($ userAgent ['string ' ]))
55
+ {
56
+ return $ userAgent ;
57
+ }
58
+
54
59
// build regex that matches phrases for known browsers
55
60
// (e.g. "Firefox/2.0" or "MSIE 6.0" (This only matches the major and minor
56
61
// version numbers. E.g. "2.0.0.6" is parsed as simply "2.0"
You can’t perform that action at this time.
0 commit comments