Bug #22511
closedgetBrowserInfo delivers wrong info
0%
Description
As the most userAgents starts with Mozilla, we always get "netscape" as result which is wrong and doesn't help.
The parsing of UA is not precise and compares the wrong way.
This patch use a regular expression and a list of the known browsers, it's easy to maintain and to add new browsers.
As the TS condition only need one browser, and some browsers return more than one result, the last result is taken as main browser info. But an additional array "all" contains all founded browsers in UA.
The result parsing isn't perfect as there are many possible UA strings, but it reflects the most common browsers.
Example on my machine:
Chrome
[useragent] => Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1045 Safari/532.5
[browser] => safari
[version] => 532.5
[all] => Array
(
[webkit] => 532.5
[chrome] => 4.1
[safari] => 532.5
)
[system] => winNT
IE
[useragent] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.1; .NET CLR 3.0.30729; AskTB5.4)
[browser] => msie
[version] => 7.0
[all] => Array
(
[msie] => 7.0
)
[system] => winNT
Firefox
[useragent] => Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.3) Gecko/20100401 Ant.com Toolbar 2.0.1 Firefox/3.6.3
[browser] => firefox
[version] => 3.6
[all] => Array
(
[gecko] => 20100401
[firefox] => 3.6
)
[system] => winNT
Safari
[useragent] => Mozilla/5.0 (Windows; U; Windows NT 6.0; de-DE) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7
[browser] => safari
[version] => 531.22
[all] => Array
(
[webkit] => 531.22
[safari] => 531.22
)
[system] => winNT
(issue imported from #M14201)
Files
Updated by Steffen Kamper almost 14 years ago
committed to svn
4_3 rev 7437
trunk rev 7438