From 8f4c1137187fdfe6696a996d8cfd9f945925eb30 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Mon, 29 Jul 2013 02:11:46 +0000 Subject: [PATCH] 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 --- wp-includes/class-http.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php index cfd4d47c45..87558df48d 100644 --- a/wp-includes/class-http.php +++ b/wp-includes/class-http.php @@ -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'] ) {