From f1cad2c2ae36cb5bc5b03e608026d81c56c99815 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Sun, 17 Jan 2010 08:15:52 +0000 Subject: [PATCH] Allow cURL to follow redirects when running under safe_mode or open_basedir. See #11305 git-svn-id: https://develop.svn.wordpress.org/trunk@12747 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/http.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/wp-includes/http.php b/wp-includes/http.php index d14c498f9f..60c2da1355 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -1397,6 +1397,15 @@ class WP_Http_Curl { if ( true === $r['decompress'] && true === WP_Http_Encoding::should_decode($theHeaders['headers']) ) $theBody = WP_Http_Encoding::decompress( $theBody ); + // See #11605 - When running under safe mode, redirection is disabled above. Handle it manually. + if ( !empty($theHeaders['headers']['location']) && (ini_get('safe_mode') || ini_get('open_basedir')) ) { + if ( $r['redirection']-- > 0 ) { + return $this->request($theHeaders['headers']['location'], $r); + } else { + return new WP_Error('http_request_failed', __('Too many redirects.')); + } + } + return array('headers' => $theHeaders['headers'], 'body' => $theBody, 'response' => $response, 'cookies' => $theHeaders['cookies']); }