WordPress.org

Make WordPress Core

Changeset 38485


Ignore:
Timestamp:
08/31/2016 10:00:53 PM (3 years ago)
Author:
jeremyfelt
Message:

HTTP: Handle an edgecase within the URI parsing library included in Requests, where if a double slash exists at the start of the path the URL is passed to cURL malformed.

Merge of [38429] to the 4.6 branch.

Props dd32, flixos90 for initial patch.
Fixes #37733.

Location:
branches/4.6
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/class-http.php

    r38461 r38485  
    363363        }
    364364
     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 );
     367
    365368        try {
    366369            $requests_response = Requests::request( $url, $headers, $data, $type, $options );
  • branches/4.6/tests/phpunit/tests/http/base.php

    r37428 r38485  
    377377    }
    378378
     379    /**
     380     * @ticket 37733
     381     */
     382    function test_url_with_double_slashes_path() {
     383        $url = $this->redirection_script . '?rt=' . 0;
     384
     385        $path = parse_url( $url, PHP_URL_PATH );
     386        $url = str_replace( $path, '/' . $path, $url );
     387
     388        $res = wp_remote_request( $url );
     389        $this->assertNotWPError( $res );
     390    }
     391
    379392
    380393}
Note: See TracChangeset for help on using the changeset viewer.