Browser detection on the verge of IE6’s death

Internet Explorer 6 is on the verge of death. Google will phase out support of this old fellow very soon. FINALLY I might add. While they will invite IE6 users to install Chrome, Firefox or some other modern browser, other websites redirect old browsers to their mobile sites. So it is important to minimize false positives in order not to confuse or aggravate users.

Just out of curiosity I have examined about 1 million Internet Explorer HTTP requests. The shocking result: about 5% of them were far from being unambiguous. Want to see examples? Look at this:

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 7.0; Win32; 1&1); .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Mozilla/4.0 (compatible; MSIE 7.0; Win32; 1&1); Mozilla/4.0 (compatible; MSIE 7.0; Win32; 1&1))

This is a mess to say the least. It’s an IE 8 alright, but if a program does look for MSIE 7, this user agent would match too.

IE 6 is also affected. I have encountered user agent strings with up to three different “MSIE \d” matches, this one for example:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 8.0; Win32; WEB.DE); SIMBAR={omitted}; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

This string matches MSIE 8, MSIE 7, and MSIE 6. You cannot even assume that the first MSIE match would indicate the browsers real version.

Conclusion

I do not know what the cause of all this is, maybe poorly written browser extensions. In any case, you cannot reliably detect browsers by matching a single string anymore. Developers, watch out. Things got complicated again, thanks to Microsoft :)

One way to detect an Internet Explorer’s real version could be to do a regexp match for “MSIE (\d)” and then take the highest version number as indicator.


Posted

in

by

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.