Make WordPress Core

Ticket #8618: 8618.wp27.diff

File 8618.wp27.diff, 1.5 KB (added by jacobsantos, 16 years ago)

Patch for WordPress 2.7 Branch

  • http.php

     
    391391         * @static
    392392         *
    393393         * @param string $body Body content
    394          * @return bool|string|WP_Error False if not chunked encoded. WP_Error on failure. Chunked decoded body on success.
     394         * @return string Chunked decoded body on success or raw body on failure.
    395395         */
    396396        function chunkTransferDecode($body) {
    397397                $body = str_replace(array("\r\n", "\r"), "\n", $body);
     
    402402                $parsedBody = '';
    403403                //$parsedHeaders = array(); Unsupported
    404404
    405                 $done = false;
    406 
    407                 do {
     405                while ( true ) {
    408406                        $hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match );
    409407
    410408                        if ( $hasChunk ) {
    411                                 if ( empty($match[1]) ) {
    412                                         return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
    413                                 }
     409                                if ( empty($match[1]) )
     410                                        return $body;
    414411
    415412                                $length = hexdec( $match[1] );
    416413                                $chunkLength = strlen( $match[0] );
     
    420417
    421418                                $body = ltrim(str_replace(array($match[0], $strBody), '', $body), "\n");
    422419
    423                                 if( "0" == trim($body) ) {
    424                                         $done = true;
     420                                if( "0" == trim($body) )
    425421                                        return $parsedBody; // Ignore footer headers.
    426                                         break;
    427                                 }
    428422                        } else {
    429                                 return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
     423                                return $body;
    430424                        }
    431                 } while ( false === $done );
     425                }
    432426        }
    433427}
    434428