jenssegers / agent

👮 A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect
https://jenssegers.com
MIT License
4.54k stars 476 forks source link

IE9 on Windows 7 logs as IE7 #26

Closed vicrau closed 9 years ago

jenssegers commented 9 years ago

Example user agent?

vicrau commented 9 years ago

I have the following code:

$browser = Agent::browser();
$browserVersion = Agent::version($browser);
$platform = Agent::platform();
$platformVersion = Agent::version($platform);
$agent = $platform . " " . $platformVersion . " -- " . $browser . " " . $browserVersion;

And it outputs: Windows 6.1 -- IE 7.0

I asked for a screenshot with more info about the browser:

image001

vicrau commented 9 years ago

this is the user-agent from the same user as the screenshot:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8; Zune 4.7; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)

jenssegers commented 9 years ago

Isn't MSIE 7.0 Internet Explorer 7? That's one weird user agent string.

vicrau commented 9 years ago

http://www.useragentstring.com/ tells me this:

Internet Explorer version 7.0 (MSIE 9.0 in 7.0 Compatibility View)

Probably some it-restrictions within big firms

jenssegers commented 9 years ago

Apparently Trident/5.0 means that it's coming from an IE9 browser. It's a bit of an edge case actually. To fix this I would have to add custom code for IE only, which I would rather not do of course :)

In case of IE, you could try to check for:

Agent::version('Trident');

This will return 5 in this case. To get the actual IE number, you need to add 4 to it.

vicrau commented 9 years ago

ok, thanks!

I'll try to convince the customer to disable that mode first :-)