-
Notifications
You must be signed in to change notification settings - Fork 112
bugfix: UTF8 encoding in result response from sandbox, corrupts json response #655
Conversation
$responseHeaderSize = strlen($result) - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); | ||
$responseHeaders = substr($result, 0, $responseHeaderSize); | ||
$result = substr($result, $responseHeaderSize); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@braebot
removed
Hey @bhoehl ! You are absolutely right. I will go ahead test these changes out soon. Thanks again for your PR. |
@jaypatel512 Thanks Bernd |
Good news ! We have made a new release with your PR fixes. You can download v1.8.0 with your changes. |
Thank you! Bernd On Thursday, 29 September 2016, Jay [email protected] wrote:
|
@jaypatel512
file /lib/PayPal/Core\PayPalHttpConnection.php line 150 reads
// Get Request and Response Headers
$requestHeaders = curl_getinfo($ch, CURLINFO_HEADER_OUT);
//Using alternative solution to CURLINFO_HEADER_SIZE as it throws invalid number when called using PROXY.
$responseHeaderSize = strlen($result) - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
$responseHeaders = substr($result, 0, $responseHeaderSize);
$result = substr($result, $responseHeaderSize);
The response getting from curl_exec is a string, which is binary. In my case strlen is treating this binary string as UTF8 and is returning a different strlen than the string is when written to disk, using characters like 'äöü ... '. strlen seems to be replaced with mb_strlen, which then uses the default encoding ( UTF8 ).
A better approach is to use mb_strlen in combination with 8bit encoding.
Any idea, if utf_decode has to be used, too ?
see: php.ini using mbstring.func_overload