This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
bugfix: UTF8 encoding in result response from sandbox, corrupts json response #655
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@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