Make WordPress Core

Ticket #10163: 10163.diff

File 10163.diff, 1.8 KB (added by dd32, 14 years ago)
  • wp-includes/http.php

     
    17841789         * @return string|bool False on failure.
    17851790         */
    17861791        function decompress( $compressed, $length = null ) {
    1787                 $decompressed = gzinflate( $compressed );
     1792                $decompressed = WP_Http_Encoding::compatible_gzinflate( $compressed );
    17881793
    17891794                if ( false !== $decompressed )
    17901795                        return $decompressed;
     
    18051810        }
    18061811
    18071812        /**
     1813         * Decompression of deflated string while staying compatible with the majority of servers.
     1814         *
     1815         * Certain Servers will return deflated data with headers which PHP's gziniflate()
     1816         * function cannot handle out of the box. The following function lifted from
     1817         * http://au2.php.net/manual/en/function.gzinflate.php#77336 will attempt to deflate
     1818         * the various return forms used.
     1819         *
     1820         * @since 2.8.1
     1821         * @link http://au2.php.net/manual/en/function.gzinflate.php#77336
     1822         *
     1823         * @param string $gzData String to decompress.
     1824         * @return string|bool False on failure.
     1825         */
     1826        function compatible_gzinflate($gzData) {
     1827                if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) {
     1828                        $i = 10;
     1829                        $flg = ord( substr($gzData, 3, 1) );
     1830                        if ( $flg > 0 ) {
     1831                                if ( $flg & 4 ) {
     1832                                        list($xlen) = unpack('v', substr($gzData, $i, 2) );
     1833                                        $i = $i + 2 + $xlen;
     1834                                }
     1835                                if ( $flg & 8 )
     1836                                        $i = strpos($gzData, "\0", $i) + 1;
     1837                                if ( $flg & 16 )
     1838                                        $i = strpos($gzData, "\0", $i) + 1;
     1839                                if ( $flg & 2 )
     1840                                        $i = $i + 2;
     1841                        }
     1842                        return gzinflate( substr($gzData, $i, -8) );
     1843                } else {
     1844                        return false;
     1845                }
     1846        }
     1847
     1848        /**
    18081849         * What encoding types to accept and their priority values.
    18091850         *
    18101851         * @since 2.8