Bug Tracker

Ticket #3169 (closed bug: duplicate)

Opened 6 years ago

Last modified 2 years ago

Browser Detection is incorrect

Reported by: chrisbarr Owned by: flesler
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc:
Blocking: Blocked by:

Description

I was trying to make some IE7 specific code and I soon realized that IE7 is incorrectly reported as version 6.0 in JQuery. Open up IE7 and head to  http://docs.jquery.com/Utilities/jQuery.browser and then head to another JS based test like  http://www.quirksmode.org/js/detect.html and you will see that it's being reported differently.

On the same note, I'm also running Firefox 3 and It's being reported as version 1.9.0.1 by JQuery.

Attachments

ie7-version[5791].diff Download (411 bytes) - added by flesler 6 years ago.
What do you think about this patch ?

Change History

comment:1 Changed 6 years ago by flesler

  • need changed from Review to Test Case
  • Priority changed from major to minor
  • Component changed from site to core

Can you add the userAgent of both browsers ? Get into  this link and copy paste it into here (the version too please).

Btw, check the link that says "modified version" and see if the version reported is fixed in this one.

comment:2 Changed 6 years ago by jamiethompso

This shouldn't have a minor priority. browser.version returns 6.0 in many installations of IE7. This is because the user agent string contains both "compatible; MSIE 7.0;" and "compatible; MSIE 6.0;" and the result varies depending on which is presented first in the string.

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)

The current regexp "userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ )" is no longer adequate for differentiating between IE6 and IE7.

A simple test like typeof document.body.style.maxHeight !== "undefined" would help to differentiate between a browser that really is IE6 or just IE7 presenting itself oddly.

Obviously as I say, this is pretty easy to workaround if you know about it. But this is a massive trip up for those who don't and it wreaks havoc with  plugins that try and use browser.version to apply hooks into CSS workarounds for IE6.

comment:3 Changed 6 years ago by flesler

  • Owner set to flesler
  • Priority changed from minor to major
  • Status changed from new to assigned

comment:4 Changed 6 years ago by jamiethompso

Update: It seems that in some cases, because of a bug IE7 actually returns a user agent string of:

Mozilla/4.0 (compatible; MSIE 6.0)

The reasons for this are  explained on my blog but revolve arounf browser toolbars and spyware messing with registry entries relating to the user agent string

Microsoft bashing aside, it looks as though accurately determining the Internet Explorer version has to involve more than just doing a regexp on the user agent string. IE7 is just far too unreliable in this respect.

I guess the question is should jQuery.browser.version simply represent what the user agent string reports or should it try it's best to report the actual browser version (using object detection and such) ?

comment:5 Changed 6 years ago by flesler

  • need changed from Test Case to Patch

Ok yes, We could add a specific check for IE7, lemme pull out a patch.

Changed 6 years ago by flesler

What do you think about this patch ?

comment:6 Changed 6 years ago by flesler

Ok, that's wrong, it won't catch IE8...

comment:7 Changed 6 years ago by jamiethompso

How about?

jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && this.XMLHttpRequest

comment:8 Changed 6 years ago by emartin24

What about something like:

Fix copies of IE7 that report MSIE 6.0 jQuery.browser.version = jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && windowXMLHttpRequest? ?

"7.0" : jQuery.browser.version;

comment:9 Changed 6 years ago by emartin24

Sorry:

// Fix copies of IE7 that report MSIE 6.0
jQuery.browser.version = jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && window["XMLHttpRequest"] ? 
	"7.0" : 
	jQuery.browser.version;

comment:10 Changed 6 years ago by pschelotto

And how about changing:

userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ )

by

userAgent.match( /.*?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ )

(tested in ie6, ie7 and Firefox)

comment:12 Changed 6 years ago by dmethvin

Duplicate of #2661

comment:13 Changed 6 years ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to duplicate
Note: See TracTickets for help on using tickets.