From 651835bbf9b4d25595909f6098761ae359816561 Mon Sep 17 00:00:00 2001 From: Bernd Hoehl Date: Thu, 22 Sep 2016 13:18:18 +0200 Subject: [PATCH 1/4] using mb_ functions with 8bit encoding --- lib/PayPal/Core/PayPalHttpConnection.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/PayPal/Core/PayPalHttpConnection.php b/lib/PayPal/Core/PayPalHttpConnection.php index 7e809ec..1020735 100644 --- a/lib/PayPal/Core/PayPalHttpConnection.php +++ b/lib/PayPal/Core/PayPalHttpConnection.php @@ -146,12 +146,12 @@ class PayPalHttpConnection throw $ex; } - // 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); + // 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 = mb_strlen($result,'8bit') - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); + $responseHeaders = mb_substr($result, 0, $responseHeaderSize, '8bit'); + $result = mb_substr($result, $responseHeaderSize, null, '8bit'); $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"); From fb1be9ca23284d380b9015e1069405d8a9b5f239 Mon Sep 17 00:00:00 2001 From: Bernd Hoehl Date: Thu, 22 Sep 2016 13:19:49 +0200 Subject: [PATCH 2/4] turning tabs into spaces --- lib/PayPal/Core/PayPalHttpConnection.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/PayPal/Core/PayPalHttpConnection.php b/lib/PayPal/Core/PayPalHttpConnection.php index 1020735..ce66cda 100644 --- a/lib/PayPal/Core/PayPalHttpConnection.php +++ b/lib/PayPal/Core/PayPalHttpConnection.php @@ -146,12 +146,12 @@ class PayPalHttpConnection throw $ex; } - // 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 = mb_strlen($result,'8bit') - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); - $responseHeaders = mb_substr($result, 0, $responseHeaderSize, '8bit'); - $result = mb_substr($result, $responseHeaderSize, null, '8bit'); + // 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 = mb_strlen($result,'8bit') - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); + $responseHeaders = mb_substr($result, 0, $responseHeaderSize, '8bit'); + $result = mb_substr($result, $responseHeaderSize, null, '8bit'); $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"); From d168a029f9d6a8bb371cf8b7776977524a2e2811 Mon Sep 17 00:00:00 2001 From: Bernd Hoehl Date: Thu, 22 Sep 2016 14:50:35 +0200 Subject: [PATCH 3/4] checking if mb_strlen exists --- lib/PayPal/Core/PayPalHttpConnection.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/PayPal/Core/PayPalHttpConnection.php b/lib/PayPal/Core/PayPalHttpConnection.php index ce66cda..91c07fd 100644 --- a/lib/PayPal/Core/PayPalHttpConnection.php +++ b/lib/PayPal/Core/PayPalHttpConnection.php @@ -149,9 +149,16 @@ class PayPalHttpConnection // 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 = mb_strlen($result,'8bit') - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); - $responseHeaders = mb_substr($result, 0, $responseHeaderSize, '8bit'); - $result = mb_substr($result, $responseHeaderSize, null, '8bit'); + 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); + + } $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"); From 667d574ec063f6638286548f49c6ae5ed9061f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20H=C3=B6hl?= Date: Fri, 23 Sep 2016 20:13:21 +0200 Subject: [PATCH 4/4] removing newline --- lib/PayPal/Core/PayPalHttpConnection.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/PayPal/Core/PayPalHttpConnection.php b/lib/PayPal/Core/PayPalHttpConnection.php index 91c07fd..2e144a2 100644 --- a/lib/PayPal/Core/PayPalHttpConnection.php +++ b/lib/PayPal/Core/PayPalHttpConnection.php @@ -157,7 +157,6 @@ class PayPalHttpConnection $responseHeaderSize = strlen($result) - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD); $responseHeaders = substr($result, 0, $responseHeaderSize); $result = substr($result, $responseHeaderSize); - } $this->logger->debug("Request Headers \t: " . str_replace("\r\n", ", ", $requestHeaders));