WP_HTTP: Curl: When using Stream-to-file on servers using mbstring.func_overload ensure that the file is written out correctly. Props DrProtocols. See #25061 for trunk

git-svn-id: https://develop.svn.wordpress.org/trunk@25051 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2013-08-18 08:17:48 +00:00
parent 6262af65df
commit cff05f9997
1 changed files with 11 additions and 1 deletions

View File

@ -1394,6 +1394,11 @@ class WP_Http_Curl {
* @return int * @return int
*/ */
private function stream_body( $handle, $data ) { private function stream_body( $handle, $data ) {
if ( function_exists( 'ini_get' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ) && function_exists( 'mb_internal_encoding' ) ) {
$mb_encoding = mb_internal_encoding();
mb_internal_encoding( 'ISO-8859-1' );
}
if ( $this->max_body_length && ( strlen( $this->body ) + strlen( $data ) ) > $this->max_body_length ) if ( $this->max_body_length && ( strlen( $this->body ) + strlen( $data ) ) > $this->max_body_length )
$data = substr( $data, 0, ( $this->max_body_length - strlen( $this->body ) ) ); $data = substr( $data, 0, ( $this->max_body_length - strlen( $this->body ) ) );
@ -1402,7 +1407,12 @@ class WP_Http_Curl {
else else
$this->body .= $data; $this->body .= $data;
return strlen( $data ); $data_length = strlen( $data );
if ( isset( $mb_encoding ) )
mb_internal_encoding( $mb_encoding );
return $data_length;
} }
/** /**