Make WordPress Core

Changeset 38727


Ignore:
Timestamp:
10/05/2016 03:23:54 AM (10 years ago)
Author:
dd32
Message:

HTTP: Update Requests to master (0048f3c) which fixes a number of outstanding issues.

Fixes #38070, #37733 by reverting part of [38429] and using the fix in Requests.
Fixes #37992 allowing for connecting to SSL resources on ports other than 443.
Fixes #37991 by not sending default ports in the Host: header.
Fixes #37839 to match and decode Chunked responses correctly.
Fixes #38232 allowing a SSL connection to ignore the hostname of the certificate when verification is disabled.

Location:
trunk/src/wp-includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/Requests/IRI.php

    r38049 r38727  
    689689                if ($this->ipath !== '' &&
    690690                        (
    691                                 $isauthority && (
    692                                         $this->ipath[0] !== '/' ||
    693                                         substr($this->ipath, 0, 2) === '//'
    694                                 ) ||
     691                                $isauthority && $this->ipath[0] !== '/' ||
    695692                                (
    696693                                        $this->scheme === null &&
  • trunk/src/wp-includes/Requests/Transport/cURL.php

    r38274 r38727  
    376376                curl_setopt($this->handle, CURLOPT_REFERER, $url);
    377377                curl_setopt($this->handle, CURLOPT_USERAGENT, $options['useragent']);
    378                 curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers);
    379 
     378                if (!empty($headers)) {
     379                        curl_setopt($this->handle, CURLOPT_HTTPHEADER, $headers);
     380                }
    380381                if ($options['protocol_version'] === 1.1) {
    381382                        curl_setopt($this->handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     
    459460         * @return integer Length of provided data
    460461         */
    461         protected function stream_body($handle, $data) {
     462        public function stream_body($handle, $data) {
    462463                $this->hooks->dispatch('request.progress', array($data, $this->response_bytes, $this->response_byte_limit));
    463464                $data_length = strlen($data);
  • trunk/src/wp-includes/Requests/Transport/fsockopen.php

    r38049 r38727  
    7171                if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') {
    7272                        $remote_socket = 'ssl://' . $host;
    73                         $url_parts['port'] = 443;
     73                        if (!isset($url_parts['port'])) {
     74                                $url_parts['port'] = 443;
     75                        }
    7476
    7577                        $context_options = array(
     
    98100
    99101                        if (isset($options['verifyname']) && $options['verifyname'] === false) {
     102                                $context_options['verify_peer_name'] = false;
    100103                                $verifyname = false;
    101104                        }
     
    172175                        $out .= sprintf('Host: %s', $url_parts['host']);
    173176
    174                         if ($url_parts['port'] !== 80) {
     177                        if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) {
    175178                                $out .= ':' . $url_parts['port'];
    176179                        }
  • trunk/src/wp-includes/class-http.php

    r38470 r38727  
    329329                if ( ! $r['sslverify'] ) {
    330330                        $options['verify'] = false;
     331                        $options['verifyname'] = false;
    331332                } else {
    332333                        $options['verify'] = $r['sslcertificates'];
     
    358359                        }
    359360                }
    360 
    361                 // Work around a bug in Requests when the path starts with // See https://github.com/rmccue/Requests/issues/231
    362                 $url = preg_replace( '!^(\w+://[^/]+)//(.*)$!i', '$1/$2', $url );
    363361
    364362                try {
  • trunk/src/wp-includes/class-requests.php

    r38163 r38727  
    750750         */
    751751        protected static function decode_chunked($data) {
    752                 if (!preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', trim($data))) {
     752                if (!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) {
    753753                        return $data;
    754754                }
     755
     756
    755757
    756758                $decoded = '';
     
    758760
    759761                while (true) {
    760                         $is_chunked = (bool) preg_match('/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded, $matches);
     762                        $is_chunked = (bool) preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', $encoded, $matches);
    761763                        if (!$is_chunked) {
    762764                                // Looks like it's not chunked after all
Note: See TracChangeset for help on using the changeset viewer.