[TYPO3-core] RFC: #14201: getBrowserInfo delivers wrong info
Steffen Kamper
info at sk-typo3.de
Mon Apr 26 11:03:48 CEST 2010
Hi,
This is an SVN patch request.
Type: bugfix
Bugtracker references:
http://bugs.typo3.org/view.php?id=14201
Branches:
trunk, 4_3
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
vg Steffen
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 14201.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100426/d63113bf/attachment.asc>
More information about the TYPO3-team-core
mailing list