WordPress.org

Make WordPress Core

Changeset 41605


Ignore:
Timestamp:
09/27/2017 07:59:14 AM (2 years ago)
Author:
dd32
Message:

Standardise on performing api.WordPress.org requests over SSL when possible, falling back to non-SSL when appropriate.
This also standardises the User-Agent used when communicating with WordPress.org, allowing for more consistent version detection.

Fixes #42004.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-community-events.php

    r41316 r41605  
    9393        }
    9494
    95         $api_url        = 'https://api.wordpress.org/events/1.0/';
    96         $request_args   = $this->get_request_args( $location_search, $timezone );
     95        // include an unmodified $wp_version
     96        include( ABSPATH . WPINC . '/version.php' );
     97
     98        $api_url      = 'http://api.wordpress.org/events/1.0/';
     99        $request_args = $this->get_request_args( $location_search, $timezone );
     100        $request_args['user-agent'] = 'WordPress/' . $wp_version . '; ' . home_url( '/' );
     101
     102        if ( wp_http_supports( array( 'ssl' ) ) ) {
     103            $api_url = set_url_scheme( $api_url, 'https' );
     104        }
     105
    97106        $response       = wp_remote_get( $api_url, $request_args );
    98107        $response_code  = wp_remote_retrieve_response_code( $response );
  • trunk/src/wp-admin/includes/credits.php

    r38705 r41605  
    1616 */
    1717function wp_credits() {
    18     $wp_version = get_bloginfo( 'version' );
     18    // include an unmodified $wp_version
     19    include( ABSPATH . WPINC . '/version.php' );
     20
    1921    $locale = get_user_locale();
    2022
     
    2527        || ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
    2628    ) {
    27         $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}" );
     29        $url = "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}";
     30        $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
     31
     32        if ( wp_http_supports( array( 'ssl' ) ) ) {
     33            $url = set_url_scheme( $url, 'https' );
     34        }
     35
     36        $response = wp_remote_get( $url, $options );
    2837
    2938        if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
  • trunk/src/wp-admin/includes/dashboard.php

    r41200 r41605  
    15101510
    15111511    if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
     1512        // include an unmodified $wp_version
     1513        include( ABSPATH . WPINC . '/version.php' );
     1514
     1515        $url = 'http://api.wordpress.org/core/browse-happy/1.1/';
    15121516        $options = array(
    1513             'body'          => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
    1514             'user-agent'    => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url()
     1517            'body'       => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
     1518            'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' )
    15151519        );
    15161520
    1517         $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options );
     1521        if ( wp_http_supports( array( 'ssl' ) ) ) {
     1522            $url = set_url_scheme( $url, 'https' );
     1523        }
     1524
     1525        $response = wp_remote_post( $url, $options );
    15181526
    15191527        if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
  • trunk/src/wp-admin/includes/import.php

    r38705 r41605  
    132132    if ( ! $popular_importers ) {
    133133        $url = add_query_arg( array(
    134             'locale'  => get_user_locale(),
     134            'locale'  => $locale,
    135135            'version' => $wp_version,
    136136        ), 'http://api.wordpress.org/core/importers/1.1/' );
    137         $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() );
     137        $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
     138
     139        if ( wp_http_supports( array( 'ssl' ) ) ) {
     140            $url = set_url_scheme( $url, 'https' );
     141        }
     142
    138143        $response = wp_remote_get( $url, $options );
    139144        $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true );
  • trunk/src/wp-admin/includes/plugin-install.php

    r41289 r41605  
    142142
    143143    if ( false === $res ) {
     144        // include an unmodified $wp_version
     145        include( ABSPATH . WPINC . '/version.php' );
     146
    144147        $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
    145148        if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
     
    148151        $http_args = array(
    149152            'timeout' => 15,
     153            'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
    150154            'body' => array(
    151155                'action' => $action,
  • trunk/src/wp-admin/includes/theme.php

    r40313 r41605  
    449449
    450450    if ( ! $res ) {
     451        // include an unmodified $wp_version
     452        include( ABSPATH . WPINC . '/version.php' );
     453
    451454        $url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
    452455        if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
     
    454457
    455458        $http_args = array(
     459            'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
    456460            'body' => array(
    457461                'action' => $action,
  • trunk/src/wp-includes/update.php

    r40575 r41605  
    302302            'all'          => wp_json_encode( true ),
    303303        ),
    304         'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
     304        'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' )
    305305    );
    306306
     
    480480            'locale'       => wp_json_encode( $locales ),
    481481        ),
    482         'user-agent'    => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
     482        'user-agent'    => 'WordPress/' . $wp_version . '; ' . home_url( '/' )
    483483    );
    484484
Note: See TracChangeset for help on using the changeset viewer.