From f40bc45b6f968b5c0fcb2a81c3f41fd1794b2d68 Mon Sep 17 00:00:00 2001 From: dd32 Date: Mon, 19 Sep 2011 14:43:43 +0000 Subject: [PATCH] Add inflation support for java.util.zip.Deflater in WP_Http_Encoding::compatible_gzinflate(). Fixes #18273 git-svn-id: http://svn.automattic.com/wordpress/trunk@18718 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-http.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php index 3b50a98dce..fceff23608 100644 --- a/wp-includes/class-http.php +++ b/wp-includes/class-http.php @@ -1636,6 +1636,8 @@ class WP_Http_Encoding { * @return string|bool False on failure. */ function compatible_gzinflate($gzData) { + + // Compressed data might contain a full header, if so strip it for gzinflate() if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) { $i = 10; $flg = ord( substr($gzData, 3, 1) ); @@ -1651,10 +1653,17 @@ class WP_Http_Encoding { if ( $flg & 2 ) $i = $i + 2; } - return gzinflate( substr($gzData, $i, -8) ); - } else { - return false; + $decompressed = @gzinflate( substr($gzData, $i, -8) ); + if ( false !== $decompressed ) + return $decompressed; } + + // Compressed data from java.util.zip.Deflater amongst others. + $decompressed = @gzinflate( substr($gzData, 2) ); + if ( false !== $decompressed ) + return $decompressed; + + return false; } /**