WP_HTTP: When multiple location headers are specified, use the last specified location url as the redirect location. Fixes #16890

git-svn-id: https://develop.svn.wordpress.org/trunk@24846 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2013-07-29 02:11:46 +00:00
parent 9ebe1e049b
commit 8f4c113718

View File

@ -617,7 +617,13 @@ class WP_Http {
if ( $args['redirection']-- <= 0 )
return new WP_Error( 'http_request_failed', __('Too many redirects.') );
$redirect_location = WP_HTTP::make_absolute_url( $response['headers']['location'], $url );
$redirect_location = $response['headers']['location'];
// If there were multiple Location headers, use the last header specified
if ( is_array( $redirect_location ) )
$redirect_location = array_pop( $redirect_location );
$redirect_location = WP_HTTP::make_absolute_url( $redirect_location, $url );
// POST requests should not POST to a redirected location
if ( 'POST' == $args['method'] ) {