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

git-svn-id: http://core.svn.wordpress.org/trunk@24846 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2013-07-29 02:11:46 +00:00
parent d6656cc1f1
commit ac424c08ca
1 changed files with 7 additions and 1 deletions

View File

@ -617,7 +617,13 @@ class WP_Http {
if ( $args['redirection']-- <= 0 ) if ( $args['redirection']-- <= 0 )
return new WP_Error( 'http_request_failed', __('Too many redirects.') ); 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 // POST requests should not POST to a redirected location
if ( 'POST' == $args['method'] ) { if ( 'POST' == $args['method'] ) {