Skip to content

Commit

Permalink
Merge pull request #18 from logeecom/hotfix/string-encoding
Browse files Browse the repository at this point in the history
Hotfix - string encoding / Release v1.5.2
  • Loading branch information
llfrometa89 authored Dec 4, 2019
2 parents a957371 + de6a07a commit e569fe6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased](https://github.com/packlink-dev/ecommerce_module_core/compare/master...dev)

## [v1.5.2](https://github.com/packlink-dev/ecommerce_module_core/compare/v1.5.1...v1.5.2) - 2019-12-04
### Changed
- Replaced `substr` with `mb_substring` to prevent cutting the string in the middle of the special unicode character.

## [v1.5.1](https://github.com/packlink-dev/ecommerce_module_core/compare/v1.5.0...v1.5.1) - 2019-11-28
### Changed
- `AjaxService.js:call` method now removes the protocol from the URL in order to use the current page's protocol/.
- `AjaxService.js:call` method now removes the protocol from the URL in order to use the current page's protocol.

## [v1.5.0](https://github.com/packlink-dev/ecommerce_module_core/compare/v1.4.1...v1.5.0) - 2019-11-18
### Added
Expand Down
2 changes: 1 addition & 1 deletion src/BusinessLogic/Http/DTO/Draft.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,6 @@ private function getContent()

$content = implode(', ', $this->content);

return substr(str_replace($forbiddenCharacters, '', $content), 0, 60);
return mb_substr(str_replace($forbiddenCharacters, '', $content), 0, 60);
}
}
10 changes: 5 additions & 5 deletions src/Infrastructure/Http/CurlHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ protected function strip100Header($response)
{
$delimiter = "\r\n\r\n";
$needle = 'HTTP/1.1 100';
if (strpos($response, $needle) === 0) {
return substr($response, strpos($response, $delimiter) + 4);
if (mb_strpos($response, $needle) === 0) {
return mb_substr($response, mb_strpos($response, $delimiter) + 4);
}

return $response;
Expand Down Expand Up @@ -335,7 +335,7 @@ protected function getHeadersFromCurlResponse($response)
{
$headers = array();
$headersBodyDelimiter = "\r\n\r\n";
$headerText = substr($response, 0, strpos($response, $headersBodyDelimiter));
$headerText = mb_substr($response, 0, mb_strpos($response, $headersBodyDelimiter));
$headersDelimiter = "\r\n";

foreach (explode($headersDelimiter, $headerText) as $i => $line) {
Expand All @@ -362,7 +362,7 @@ protected function getBodyFromCurlResponse($response)
$headersBodyDelimiter = "\r\n\r\n";
$bodyStartingPositionOffset = 4; // number of special signs in delimiter;

return substr($response, strpos($response, $headersBodyDelimiter) + $bodyStartingPositionOffset);
return mb_substr($response, mb_strpos($response, $headersBodyDelimiter) + $bodyStartingPositionOffset);
}

/**
Expand Down Expand Up @@ -417,7 +417,7 @@ protected function adjustUrlIfNeeded($url)
$domain = parse_url($url, PHP_URL_HOST);
$options = $this->getAdditionalOptions($domain);
if (!empty($options[self::SWITCH_PROTOCOL])) {
if (strpos($url, 'http:') === 0) {
if (mb_strpos($url, 'http:') === 0) {
$url = str_replace('http:', 'https:', $url);
} else {
$url = str_replace('https:', 'http:', $url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function ($item) use ($condition, $indexMap) {

// %SEARCH
if ($firstP === 0 && $firstP === $lastP) {
return $position !== false && $position + strlen($b) === strlen($a);
return $position !== false && $position + mb_strlen($b) === mb_strlen($a);
}

return false;
Expand Down

0 comments on commit e569fe6

Please sign in to comment.