| 1 | Index: class-http.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- class-http.php (revision 15364) |
|---|
| 4 | +++ class-http.php (working copy) |
|---|
| 5 | @@ -434,6 +434,8 @@ |
|---|
| 6 | $cookies = array(); |
|---|
| 7 | $newheaders = array(); |
|---|
| 8 | foreach ( $headers as $tempheader ) { |
|---|
| 9 | + // Sanity check, this should never be true, but prevents no lines from processing. Also |
|---|
| 10 | + // the rare event that there are lines in between the headers that are empty. |
|---|
| 11 | if ( empty($tempheader) ) |
|---|
| 12 | continue; |
|---|
| 13 | |
|---|
| 14 | @@ -443,15 +445,16 @@ |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | list($key, $value) = explode(':', $tempheader, 2); |
|---|
| 18 | + $value = trim( $value ); // Remove spaces before and after for the value. |
|---|
| 19 | |
|---|
| 20 | - if ( !empty( $value ) ) { |
|---|
| 21 | + if ( $value != '' ) { |
|---|
| 22 | $key = strtolower( $key ); |
|---|
| 23 | if ( isset( $newheaders[$key] ) ) { |
|---|
| 24 | if ( !is_array($newheaders[$key]) ) |
|---|
| 25 | $newheaders[$key] = array($newheaders[$key]); |
|---|
| 26 | - $newheaders[$key][] = trim( $value ); |
|---|
| 27 | + $newheaders[$key][] = $value; |
|---|
| 28 | } else { |
|---|
| 29 | - $newheaders[$key] = trim( $value ); |
|---|
| 30 | + $newheaders[$key] = $value; |
|---|
| 31 | } |
|---|
| 32 | if ( 'set-cookie' == $key ) |
|---|
| 33 | $cookies[] = new WP_Http_Cookie( $value ); |
|---|
| 34 | @@ -491,6 +494,8 @@ |
|---|
| 35 | * Based off the HTTP http_encoding_dechunk function. Does not support UTF-8. Does not support |
|---|
| 36 | * returning footer headers. Shouldn't be too difficult to support it though. |
|---|
| 37 | * |
|---|
| 38 | + * @link http://tools.ietf.org/html/rfc2616#section-19.4.6 Process for chunked decoding. |
|---|
| 39 | + * |
|---|
| 40 | * @todo Add support for footer chunked headers. |
|---|
| 41 | * @access public |
|---|
| 42 | * @since 2.7.0 |
|---|
| 43 | @@ -512,6 +517,11 @@ |
|---|
| 44 | $hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match ); |
|---|
| 45 | |
|---|
| 46 | if ( $hasChunk ) { |
|---|
| 47 | + // http://tools.ietf.org/html/rfc2616#page-14 - Augmented BNF states what *rule |
|---|
| 48 | + // Means and the chunked encoding http://tools.ietf.org/html/rfc2616#section-3.6.1 |
|---|
| 49 | + // defined says that only one HEX character is required. In many cases during |
|---|
| 50 | + // testing, the last HEX digit will be '0' and will match. If not, then nothing |
|---|
| 51 | + // will be adversely affected. |
|---|
| 52 | if ( empty( $match[1] ) ) |
|---|
| 53 | return $body; |
|---|
| 54 | |
|---|
| 55 | @@ -1735,7 +1745,7 @@ |
|---|
| 56 | // Set everything else as a property |
|---|
| 57 | foreach ( $pairs as $pair ) { |
|---|
| 58 | $pair = rtrim($pair); |
|---|
| 59 | - if ( empty($pair) ) //Handles the cookie ending in ; which results in a empty final pair |
|---|
| 60 | + if ( $pair == '' ) //Handles the cookie ending in ; which results in a empty final pair |
|---|
| 61 | continue; |
|---|
| 62 | |
|---|
| 63 | list( $key, $val ) = strpos( $pair, '=' ) ? explode( '=', $pair ) : array( $pair, '' ); |
|---|
| 64 | @@ -1814,7 +1824,7 @@ |
|---|
| 65 | * @return string Header encoded cookie name and value. |
|---|
| 66 | */ |
|---|
| 67 | function getHeaderValue() { |
|---|
| 68 | - if ( empty( $this->name ) || empty( $this->value ) ) |
|---|
| 69 | + if ( $this->name == '' || $this->value == '' ) |
|---|
| 70 | return ''; |
|---|
| 71 | |
|---|
| 72 | return $this->name . '=' . urlencode( $this->value ); |
|---|