WordPress.org

Make WordPress Core

Changeset 10284


Ignore:
Timestamp:
12/31/2008 03:03:26 AM (9 years ago)
Author:
ryan
Message:

Chunked decoding fix from jacobsantos. fixes #8618 for 2.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7/wp-includes/http.php

    r10212 r10284  
    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) {
     
    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] );
     
    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}
Note: See TracChangeset for help on using the changeset viewer.