Correctly handle url's containing url's in WP_HTTP::make_absolute_url().

A valid relative URL could be mistaken for an absolute url if it contained a :// in any position of the url.
Fixes #28001

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


git-svn-id: http://core.svn.wordpress.org/trunk@29613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2014-10-08 05:38:18 +00:00
parent 88b635245a
commit 9962cefbec
1 changed files with 5 additions and 4 deletions

View File

@ -675,16 +675,17 @@ class WP_Http {
if ( empty( $url ) )
return $maybe_relative_path;
// Check for a scheme.
if ( false !== strpos( $maybe_relative_path, '://' ) )
return $maybe_relative_path;
if ( ! $url_parts = @parse_url( $url ) )
return $maybe_relative_path;
if ( ! $relative_url_parts = @parse_url( $maybe_relative_path ) )
return $maybe_relative_path;
// Check for a scheme on the 'relative' url
if ( ! empty( $relative_url_parts['scheme'] ) ) {
return $maybe_relative_path;
}
$absolute_path = $url_parts['scheme'] . '://' . $url_parts['host'];
if ( isset( $url_parts['port'] ) )
$absolute_path .= ':' . $url_parts['port'];