[TYPO3-core] RFC: #14201: getBrowserInfo delivers wrong info

Ernesto Baschny [cron IT] ernst at cron-it.de
Wed Apr 28 09:09:06 CEST 2010


Hi,

nice addition! Would be nice to also have a way to detect (and match)
mobile end devices (iPhones et al). Very required these days. :) I found
a regexp to do it [1].

But probably only in 4.5...

[1] http://detectmobilebrowser.com/

Cheers,
Ernesto


Steffen Kamper schrieb am 26.04.2010 11:03:
> 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
> 


More information about the TYPO3-team-core mailing list