@@ 102-120 (lines=19) @@ | ||
99 | public static function compatible_gzinflate($gzData) { |
|
100 | ||
101 | // Compressed data might contain a full header, if so strip it for gzinflate(). |
|
102 | if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) { |
|
103 | $i = 10; |
|
104 | $flg = ord( substr($gzData, 3, 1) ); |
|
105 | if ( $flg > 0 ) { |
|
106 | if ( $flg & 4 ) { |
|
107 | list($xlen) = unpack('v', substr($gzData, $i, 2) ); |
|
108 | $i = $i + 2 + $xlen; |
|
109 | } |
|
110 | if ( $flg & 8 ) |
|
111 | $i = strpos($gzData, "\0", $i) + 1; |
|
112 | if ( $flg & 16 ) |
|
113 | $i = strpos($gzData, "\0", $i) + 1; |
|
114 | if ( $flg & 2 ) |
|
115 | $i = $i + 2; |
|
116 | } |
|
117 | $decompressed = @gzinflate( substr($gzData, $i, -8) ); |
|
118 | if ( false !== $decompressed ) |
|
119 | return $decompressed; |
|
120 | } |
|
121 | ||
122 | // Compressed data from java.util.zip.Deflater amongst others. |
|
123 | $decompressed = @gzinflate( substr($gzData, 2) ); |
@@ 868-890 (lines=23) @@ | ||
865 | public static function compatible_gzinflate($gzData) { |
|
866 | // Compressed data might contain a full zlib header, if so strip it for |
|
867 | // gzinflate() |
|
868 | if (substr($gzData, 0, 3) == "\x1f\x8b\x08") { |
|
869 | $i = 10; |
|
870 | $flg = ord(substr($gzData, 3, 1)); |
|
871 | if ($flg > 0) { |
|
872 | if ($flg & 4) { |
|
873 | list($xlen) = unpack('v', substr($gzData, $i, 2)); |
|
874 | $i = $i + 2 + $xlen; |
|
875 | } |
|
876 | if ($flg & 8) { |
|
877 | $i = strpos($gzData, "\0", $i) + 1; |
|
878 | } |
|
879 | if ($flg & 16) { |
|
880 | $i = strpos($gzData, "\0", $i) + 1; |
|
881 | } |
|
882 | if ($flg & 2) { |
|
883 | $i = $i + 2; |
|
884 | } |
|
885 | } |
|
886 | $decompressed = self::compatible_gzinflate(substr($gzData, $i)); |
|
887 | if (false !== $decompressed) { |
|
888 | return $decompressed; |
|
889 | } |
|
890 | } |
|
891 | ||
892 | // If the data is Huffman Encoded, we must first strip the leading 2 |
|
893 | // byte Huffman marker for gzinflate() |