From f44d88c4e1aecc5d4c11b66adcf4a3de805c2dfd Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Sat, 16 Jan 2010 23:11:28 +0000 Subject: [PATCH] Correctly set the body on Curl requests with an empty body. Add a defensive check to WP_Http_Encoding::decompress to prevent the decompression functions running on empty strings. Fixes #11912 git-svn-id: https://develop.svn.wordpress.org/trunk@12739 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/http.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/http.php b/wp-includes/http.php index e8d1344ccd..35caa402e9 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -1360,7 +1360,10 @@ class WP_Http_Curl { if ( !empty($theResponse) ) { $headerLength = curl_getinfo($handle, CURLINFO_HEADER_SIZE); $theHeaders = trim( substr($theResponse, 0, $headerLength) ); - $theBody = substr( $theResponse, $headerLength ); + if ( strlen($theResponse) > $headerLength ) + $theBody = substr( $theResponse, $headerLength ); + else + $theBody = ''; if ( false !== strrpos($theHeaders, "\r\n\r\n") ) { $headerParts = explode("\r\n\r\n", $theHeaders); $theHeaders = $headerParts[ count($headerParts) -1 ]; @@ -1817,6 +1820,9 @@ class WP_Http_Encoding { */ function decompress( $compressed, $length = null ) { + if ( empty($compressed) ) + return $compressed; + if ( false !== ( $decompressed = @gzinflate( $compressed ) ) ) return $decompressed;