Bug Tracker

Ticket #2784: browser_version_regex_fix.diff

File browser_version_regex_fix.diff, 1.9 KB (added by bgreenlee, 13 years ago)
  • test/unit/core.js

     
    5353});
    5454
    5555test("browser", function() {
    56         expect(13);
     56        expect(14);
    5757        var browsers = {
    5858                //Internet Explorer
    5959                "Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)": "6.0",
    6060                "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)": "7.0",
     61                "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 1.1.4322)": "7.0",
    6162                /** Failing #1876
    6263                 * "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 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30)": "7.0",
    6364                 */
     
    8283                "Other browser's user agent 1.0":null
    8384        };
    8485        for (var i in browsers) {
    85                 var v = i.toLowerCase().match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ); // RegEx from Core jQuery.browser.version check
     86                var v = i.toLowerCase().match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)(?!.+opera)/ ); // RegEx from Core jQuery.browser.version check
    8687                version = v ? v[1] : null;
    8788                equals( version, browsers[i], "Checking UA string" );
    8889        }
  • src/core.js

     
    12211221
    12221222// Figure out what browser is being used
    12231223jQuery.browser = {
    1224         version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
     1224        version: (userAgent.match( /.+?(?:rv|it|ra|ie)[\/: ]([\d.]+)(?!.+opera)/ ) || [])[1],
    12251225        safari: /webkit/.test( userAgent ),
    12261226        opera: /opera/.test( userAgent ),
    12271227        msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),