From 78f4cd2c581775900f54ce3d187a1561cc107f70 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 8 Oct 2014 05:58:19 +0000 Subject: [PATCH] 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 --- wp-includes/class-http.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php index b2b00623d8..c8330e09e2 100644 --- a/wp-includes/class-http.php +++ b/wp-includes/class-http.php @@ -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'] : '/';