Make WordPress Core

Ticket #24646: 24646.diff

File 24646.diff, 6.7 KB (added by nacin, 10 years ago)

Use wp_safe_remote_*() in core.

  • wp-admin/includes/class-wp-importer.php

     
    183183
    184184                $headers = array();
    185185                $args = array();
    186                 $args['reject_unsafe_urls'] = true;
    187186                if ( true === $head )
    188187                        $args['method'] = 'HEAD';
    189188                if ( !empty( $username ) && !empty( $password ) )
     
    191190
    192191                $args['headers'] = $headers;
    193192
    194                 return wp_remote_request( $url, $args );
     193                return wp_safe_remote_request( $url, $args );
    195194        }
    196195
    197196        /**
  • wp-admin/includes/file.php

     
    497497        if ( ! $tmpfname )
    498498                return new WP_Error('http_no_file', __('Could not create Temporary file.'));
    499499
    500         $response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname, 'reject_unsafe_urls' => true ) );
     500        $response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname );
    501501
    502502        if ( is_wp_error( $response ) ) {
    503503                unlink( $tmpfname );
  • wp-includes/class-feed.php

     
    6969                        $args = array(
    7070                                'timeout' => $this->timeout,
    7171                                'redirection' => $this->redirects,
    72                                 'reject_unsafe_urls' => true,
    7372                        );
    7473
    7574                        if ( !empty($this->headers) )
     
    7877                        if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified
    7978                                $args['user-agent'] = $this->useragent;
    8079
    81                         $res = wp_remote_request($url, $args);
     80                        $res = wp_safe_remote_request($url, $args);
    8281
    8382                        if ( is_wp_error($res) ) {
    8483                                $this->error = 'WP HTTP Error: ' . $res->get_error_message();
  • wp-includes/class-oembed.php

     
    113113                $providers = array();
    114114
    115115                // Fetch URL content
    116                 if ( $html = wp_remote_retrieve_body( wp_remote_get( $url, array( 'reject_unsafe_urls' => true ) ) ) ) {
     116                if ( $html = wp_remote_retrieve_body( wp_safe_remote_get( $url ) ) ) {
    117117
    118118                        // <link> types that contain oEmbed provider URLs
    119119                        $linktypes = apply_filters( 'oembed_linktypes', array(
     
    195195         */
    196196        function _fetch_with_format( $provider_url_with_args, $format ) {
    197197                $provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args );
    198                 $response = wp_remote_get( $provider_url_with_args, array( 'reject_unsafe_urls' => true ) );
     198                $response = wp_safe_remote_get( $provider_url_with_args );
    199199                if ( 501 == wp_remote_retrieve_response_code( $response ) )
    200200                        return new WP_Error( 'not-implemented' );
    201201                if ( ! $body = wp_remote_retrieve_body( $response ) )
  • wp-includes/class-wp-xmlrpc-server.php

     
    53925392                $http_api_args = array(
    53935393                        'timeout' => 10,
    53945394                        'redirection' => 0,
    5395                         'reject_unsafe_urls' => true,
    53965395                        'limit_response_size' => 153600, // 150 KB
    53975396                );
    5398                 $linea = wp_remote_retrieve_body( wp_remote_get( $pagelinkedfrom, $http_api_args ) );
     5397                $linea = wp_remote_retrieve_body( wp_safe_remote_get( $pagelinkedfrom, $http_api_args ) );
    53995398
    54005399                if ( !$linea )
    54015400                        return $this->pingback_error( 16, __( 'The source URL does not exist.' ) );
  • wp-includes/comment.php

     
    16581658        if ( 0 === strpos($url, $uploads_dir['baseurl']) )
    16591659                return false;
    16601660
    1661         $response = wp_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0', 'reject_unsafe_urls' => true ) );
     1661        $response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
    16621662
    16631663        if ( is_wp_error( $response ) )
    16641664                return false;
     
    16711671                return false;
    16721672
    16731673        // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file)
    1674         $response = wp_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0', 'reject_unsafe_urls' => true ) );
     1674        $response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
    16751675
    16761676        if ( is_wp_error( $response ) )
    16771677                return false;
     
    19061906
    19071907        $options = array();
    19081908        $options['timeout'] = 4;
    1909         $options['reject_unsafe_urls'] = true;
    19101909        $options['body'] = array(
    19111910                'title' => $title,
    19121911                'url' => get_permalink($ID),
     
    19141913                'excerpt' => $excerpt
    19151914        );
    19161915
    1917         $response = wp_remote_post($trackback_url, $options);
     1916        $response = wp_safe_remote_post( $trackback_url, $options );
    19181917
    19191918        if ( is_wp_error( $response ) )
    19201919                return;
  • wp-includes/functions.php

     
    496496
    497497        $options = array();
    498498        $options['redirection'] = 5;
    499         $options['reject_unsafe_urls'] = true;
    500499
    501500        if ( false == $file_path )
    502501                $options['method'] = 'HEAD';
     
    503502        else
    504503                $options['method'] = 'GET';
    505504
    506         $response = wp_remote_request($url, $options);
     505        $response = wp_safe_remote_request( $url, $options );
    507506
    508507        if ( is_wp_error( $response ) )
    509508                return false;
     
    544543        if ( !empty( $deprecated ) )
    545544                _deprecated_argument( __FUNCTION__, '2.7' );
    546545
    547         $response = wp_remote_head( $url, array( 'reject_unsafe_urls' => true ) );
     546        $response = wp_safe_remote_head( $url );
    548547
    549548        if ( is_wp_error( $response ) )
    550549                return false;
     
    759758
    760759        $options = array();
    761760        $options['timeout'] = 10;
    762         $options['reject_unsafe_urls'] = true;
    763761
    764         $response = wp_remote_get( $uri, $options );
     762        $response = wp_safe_remote_get( $uri, $options );
    765763
    766764        if ( is_wp_error( $response ) )
    767765                return false;
  • wp-includes/rss.php

     
    536536 * @return Snoopy style response
    537537 */
    538538function _fetch_remote_file($url, $headers = "" ) {
    539         $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT, 'reject_unsafe_urls' => true ));
     539        $resp = wp_safe_remote_request( $url, array( 'headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT ) );
    540540        if ( is_wp_error($resp) ) {
    541541                $error = array_shift($resp->errors);
    542542