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.
Props flixos90 for initial patch. Fixes #37733 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@38429 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3b723b31ee
commit
7f2a81061a
@ -362,6 +362,9 @@ class WP_Http {
|
||||
}
|
||||
}
|
||||
|
||||
// Work around a bug in Requests when the path starts with // See https://github.com/rmccue/Requests/issues/231
|
||||
$url = preg_replace( '!^(\w+://[^/]+)//(.*)$!i', '$1/$2', $url );
|
||||
|
||||
try {
|
||||
$requests_response = Requests::request( $url, $headers, $data, $type, $options );
|
||||
|
||||
|
@ -376,5 +376,18 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
|
||||
$this->assertTrue( ! is_wp_error( $res ), print_r( $res, true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 37733
|
||||
*/
|
||||
function test_url_with_double_slashes_path() {
|
||||
$url = $this->redirection_script . '?rt=' . 0;
|
||||
|
||||
$path = parse_url( $url, PHP_URL_PATH );
|
||||
$url = str_replace( $path, '/' . $path, $url );
|
||||
|
||||
$res = wp_remote_request( $url );
|
||||
$this->assertNotWPError( $res );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user