Skip to content
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

Merged
merged 4 commits into from
Sep 26, 2016
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/PayPal/Core/PayPalHttpConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,16 @@ public function execute($data)
// 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);
if (function_exists('mb_strlen')) {
$responseHeaderSize = mb_strlen($result, '8bit') - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
$responseHeaders = mb_substr($result, 0, $responseHeaderSize, '8bit');
$result = mb_substr($result, $responseHeaderSize, null, '8bit');
} else {
$responseHeaderSize = strlen($result) - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
$responseHeaders = substr($result, 0, $responseHeaderSize);
$result = substr($result, $responseHeaderSize);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra newline here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@braebot
removed

}

$this->logger->debug("Request Headers \t: " . str_replace("\r\n", ", ", $requestHeaders));
$this->logger->debug(($data && $data != '' ? "Request Data\t\t: " . $data : "No Request Payload") . "\n" . str_repeat('-', 128) . "\n");
Expand Down