Correctly support Schemeless URLs in WP_HTTP::make_absolute_url() by respecting the 'host' field if present in the relative url.

Fixes #29886

Built from https://develop.svn.wordpress.org/trunk@29851


git-svn-id: http://core.svn.wordpress.org/trunk@29614 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2014-10-08 05:58:19 +00:00
parent 9962cefbec
commit 78f4cd2c58

View File

@ -686,9 +686,18 @@ class WP_Http {
return $maybe_relative_path;
}
$absolute_path = $url_parts['scheme'] . '://' . $url_parts['host'];
if ( isset( $url_parts['port'] ) )
$absolute_path .= ':' . $url_parts['port'];
$absolute_path = $url_parts['scheme'] . '://';
// Schemeless URL's will make it this far, so we check for a host in the relative url and convert it to a protocol-url
if ( isset( $relative_url_parts['host'] ) ) {
$absolute_path .= $relative_url_parts['host'];
if ( isset( $relative_url_parts['port'] ) )
$absolute_path .= ':' . $relative_url_parts['port'];
} else {
$absolute_path .= $url_parts['host'];
if ( isset( $url_parts['port'] ) )
$absolute_path .= ':' . $url_parts['port'];
}
// Start off with the Absolute URL path.
$path = ! empty( $url_parts['path'] ) ? $url_parts['path'] : '/';