Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.2.1

Bug #16555 mbstring.func_overload breaks decodeGzip()
Submitted: 2009-08-29 20:44 UTC Modified: 2009-09-01 18:56 UTC
From: shupp Assigned: avb
Status: Closed Package: HTTP_Request2 (version 0.4.0)
PHP Version: Irrelevant OS: linux
Roadmaps: (Not assigned)    
Subscription  



Patch fix-mbstring-overloading Revisions
Revision 2009-08-29 20:46 UTC
Developer shupp
 
Download patch

--- /usr/share/php/HTTP/Request2/Response.orig.php	2009-08-29 10:52:32.000000000 -0700
+++ /usr/share/php/HTTP/Request2/Response.php	2009-08-29 10:52:21.000000000 -0700
@@ -423,6 +423,10 @@
     */
     public static function decodeGzip($data)
     {
+        if (function_exists('mb_substr') && (2 & ini_get('mbstring.func_overload'))) {
+            $oldEncoding = mb_internal_encoding();
+            mb_internal_encoding('iso-8859-1');
+        }
         $length = strlen($data);
         // If it doesn't look like gzip-encoded data, don't bother
         if (18 > $length || strcmp(substr($data, 0, 2), "\x1f\x8b")) {
@@ -502,6 +506,10 @@
         } elseif ((0xffffffff & $dataCrc) != (0xffffffff & crc32($unpacked))) {
             throw new HTTP_Request2_Exception('Data CRC check failed');
         }
+
+        if (function_exists('mb_substr') && (2 & ini_get('mbstring.func_overload'))) {
+            mb_internal_encoding($oldEncoding);
+        }
         return $unpacked;
     }
 
@@ -525,4 +533,4 @@
         return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data);
     }
 }
-?>
\ No newline at end of file
+?>