WordPress.org

Making WordPress.org

Changeset 5949


Ignore:
Timestamp:
09/21/2017 07:10:15 PM (2 years ago)
Author:
coffee2code
Message:

Browse Happy API: Mark versions of Internet Explorer earlier than 11 as insecure.

  • Adds IE 10 & 11 user-agent strings to test data
  • Adds unit test for insecure browsers (currently just testing for IE)

Props SergeyBiryukov.
Fixes #2587.
Fixes #core40165.

Location:
sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/browsers.php

    r5947 r5949  
    2222        'Opera'             => '12.11',
    2323        'Safari'            => '5',
    24         'Internet Explorer' => '9', // Left at 9 until Windows 7 adopts 10
     24        'Internet Explorer' => '11',
    2525    );
    2626}
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/parse.php

    r5935 r5949  
    110110    $data['current_version'] = get_browser_version_from_name( $data['name'] );
    111111    $data['upgrade']         = ( ! empty( $data['current_version'] ) && version_compare( $data['version'], $data['current_version'], '<' ) );
    112     $data['insecure']        = ( 'Internet Explorer' == $data['name'] && version_compare( $data['version'], '8', '<' ) );
     112    $data['insecure']        = ( 'Internet Explorer' == $data['name'] && version_compare( $data['version'], '11', '<' ) );
    113113
    114114    return $data;
  • sites/trunk/api.wordpress.org/public_html/core/browse-happy/1.0/tests/phpunit/tests/browse-happy.php

    r5948 r5949  
    6161                'Windows Internet Explorer 9.0',
    6262            ],
     63            // #2587
     64            [
     65                'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)',
     66                'Windows Internet Explorer 10.0',
     67            ],
     68            // #2587
     69            [
     70                'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko',
     71                'Windows Internet Explorer 11',
     72            ],
    6373            [
    6474                'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.21022)',
     
    217227    }
    218228
     229    /**
     230     * @dataProvider data_browse_happy
     231     *
     232     * @param string $header 'User-Agent' header value.
     233     */
     234    function test_insecure_browsers( $header ) {
     235        $parsed = browsehappy_parse_user_agent( $header );
     236
     237        if ( 'Internet Explorer' === $parsed['name'] && version_compare( $parsed['version'], '11', '<' ) ) {
     238            $this->assertTrue( $parsed['insecure'] );
     239        }
     240    }
     241
    219242}
    220243
Note: See TracChangeset for help on using the changeset viewer.