Make WordPress Core


Ignore:
Timestamp:
09/11/2013 08:12:24 AM (13 years ago)
Author:
dd32
Message:

Switch WP_HTTP over to using the mbstring.func_overload helper functions. This change moves the check from within the Streaming-handling function to wrap the individual request, this fixes it for both cURL and Streams and any future changes to the transports which use strlen() on binary data. See #25259 See #16057

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-http.php

    r25309 r25348  
    167167                WP_Http::buildCookieHeader( $r );
    168168
     169                // Avoid issues where mbstring.func_overload is enabled
     170                mbstring_binary_safe_encoding();
     171
    169172                if ( ! isset( $r['headers']['Accept-Encoding'] ) ) {
    170173                        if ( $encoding = WP_Http_Encoding::accept_encoding( $url, $r ) )
    … …  
    188191
    189192                $response = $this->_dispatch_request( $url, $r );
     193
     194                reset_mbstring_encoding();
     195
    190196                if ( is_wp_error( $response ) )
    191197                        return $response;
    … …  
    13201326         */
    13211327        private function stream_body( $handle, $data ) {
    1322                 if ( function_exists( 'ini_get' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ) && function_exists( 'mb_internal_encoding' ) ) {
    1323                         $mb_encoding = mb_internal_encoding();
    1324                         mb_internal_encoding( 'ISO-8859-1' );
    1325                 }
    1326 
    13271328                $data_length = strlen( $data );
    13281329
    … …  
    13361337                        $bytes_written = $data_length;
    13371338                }
    1338 
    1339                 if ( isset( $mb_encoding ) )
    1340                         mb_internal_encoding( $mb_encoding );
    13411339
    13421340                // Upon event of this function returning less than strlen( $data ) curl will error with CURLE_WRITE_ERROR
Note: See TracChangeset for help on using the changeset viewer.