Make WordPress Core

Changeset 38728 for branches/4.6


Ignore:
Timestamp:
10/05/2016 03:26:37 AM (8 years ago)
Author:
dd32
Message:

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

Merges [38727] to the 4.6 branch.

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:
branches/4.6
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/Requests/IRI.php

    r38049 r38728  
    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 &&
  • branches/4.6/src/wp-includes/Requests/Transport/cURL.php

    r38338 r38728  
    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);
  • branches/4.6/src/wp-includes/Requests/Transport/fsockopen.php

    r38049 r38728  
    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            }
  • branches/4.6/src/wp-includes/class-http.php

    r38485 r38728  
    333333        if ( ! $r['sslverify'] ) {
    334334            $options['verify'] = false;
     335            $options['verifyname'] = false;
    335336        } else {
    336337            $options['verify'] = $r['sslcertificates'];
     
    362363            }
    363364        }
    364 
    365         // Work around a bug in Requests when the path starts with // See https://github.com/rmccue/Requests/issues/231
    366         $url = preg_replace( '!^(\w+://[^/]+)//(.*)$!i', '$1/$2', $url );
    367365
    368366        try {
  • branches/4.6/src/wp-includes/class-requests.php

    r38163 r38728  
    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.