From 49d1d17e53f18d5137a7aeb5c6878add6b36f9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 13 Aug 2024 18:14:57 +0000 Subject: [PATCH 1/5] attempt to fix --- src/Orchestration/Adapter/DockerAPI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Orchestration/Adapter/DockerAPI.php b/src/Orchestration/Adapter/DockerAPI.php index 056af31..18da71b 100644 --- a/src/Orchestration/Adapter/DockerAPI.php +++ b/src/Orchestration/Adapter/DockerAPI.php @@ -139,7 +139,7 @@ protected function streamCall(string $url, int $timeout = -1): array return 0; } - $originalSize = \mb_strlen($str); + $originalSize = \strlen($str); while (! empty($str)) { if ($isHeader) { @@ -164,7 +164,7 @@ protected function streamCall(string $url, int $timeout = -1): array } $currentData = ''; } else { - $currentHeader['size'] -= \mb_strlen($str); + $currentHeader['size'] -= \strlen($str); $currentData .= $str; $str = ''; } From 135aed64f292e83c1c7b5fd997d99582310ebbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 13 Aug 2024 18:25:44 +0000 Subject: [PATCH 2/5] Fix attempt --- src/Orchestration/Adapter/DockerAPI.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Orchestration/Adapter/DockerAPI.php b/src/Orchestration/Adapter/DockerAPI.php index 18da71b..3504f3c 100644 --- a/src/Orchestration/Adapter/DockerAPI.php +++ b/src/Orchestration/Adapter/DockerAPI.php @@ -141,10 +141,10 @@ protected function streamCall(string $url, int $timeout = -1): array $originalSize = \strlen($str); - while (! empty($str)) { + while (\strlen($str) > 0) { if ($isHeader) { $header = \unpack('Ctype/Cfill1/Cfill2/Cfill3/Nsize', $str); - $str = \mb_strcut($str, 8, null); + $str = \substr($str, 8, null); $isHeader = false; $currentHeader = $header; } else { @@ -152,8 +152,8 @@ protected function streamCall(string $url, int $timeout = -1): array $type = $currentHeader['type']; if (\strlen($str) >= $size) { - $currentData .= \mb_substr($str, 0, $size); - $str = \mb_strcut($str, $size, null); + $currentData .= \substr($str, 0, $size); + $str = \substr($str, $size, null); $isHeader = true; $currentHeader = null; From a0447f6ebde0ff6c1ae4ea03f858e125e68f17c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 13 Aug 2024 18:42:51 +0000 Subject: [PATCH 3/5] Use MB again --- src/Orchestration/Adapter/DockerAPI.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Orchestration/Adapter/DockerAPI.php b/src/Orchestration/Adapter/DockerAPI.php index 3504f3c..9f1220a 100644 --- a/src/Orchestration/Adapter/DockerAPI.php +++ b/src/Orchestration/Adapter/DockerAPI.php @@ -139,21 +139,21 @@ protected function streamCall(string $url, int $timeout = -1): array return 0; } - $originalSize = \strlen($str); + $originalSize = \mb_strlen($str); - while (\strlen($str) > 0) { + while (\mb_strlen($str) > 0) { if ($isHeader) { $header = \unpack('Ctype/Cfill1/Cfill2/Cfill3/Nsize', $str); - $str = \substr($str, 8, null); + $str = \mb_strcut($str, 8, null); $isHeader = false; $currentHeader = $header; } else { $size = $currentHeader['size']; $type = $currentHeader['type']; - if (\strlen($str) >= $size) { - $currentData .= \substr($str, 0, $size); - $str = \substr($str, $size, null); + if (\mb_strlen($str) >= $size) { + $currentData .= \mb_strcut($str, 0, $size); + $str = \mb_strcut($str, $size, null); $isHeader = true; $currentHeader = null; @@ -164,7 +164,7 @@ protected function streamCall(string $url, int $timeout = -1): array } $currentData = ''; } else { - $currentHeader['size'] -= \strlen($str); + $currentHeader['size'] -= \mb_strlen($str); $currentData .= $str; $str = ''; } From 7146eac7b0d03d10ba23846caabb305883ae8164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 13 Aug 2024 19:29:02 +0000 Subject: [PATCH 4/5] Remove multibyte --- src/Orchestration/Adapter/DockerAPI.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Orchestration/Adapter/DockerAPI.php b/src/Orchestration/Adapter/DockerAPI.php index 9f1220a..24be5b7 100644 --- a/src/Orchestration/Adapter/DockerAPI.php +++ b/src/Orchestration/Adapter/DockerAPI.php @@ -139,21 +139,21 @@ protected function streamCall(string $url, int $timeout = -1): array return 0; } - $originalSize = \mb_strlen($str); + $originalSize = \strlen($str); - while (\mb_strlen($str) > 0) { + while (\strlen($str) > 0) { if ($isHeader) { $header = \unpack('Ctype/Cfill1/Cfill2/Cfill3/Nsize', $str); - $str = \mb_strcut($str, 8, null); + $str = \substr($str, 8, null); $isHeader = false; $currentHeader = $header; } else { $size = $currentHeader['size']; $type = $currentHeader['type']; - if (\mb_strlen($str) >= $size) { - $currentData .= \mb_strcut($str, 0, $size); - $str = \mb_strcut($str, $size, null); + if (\strlen($str) >= $size) { + $currentData .= \substr($str, 0, $size); + $str = \strcut($str, $size, null); $isHeader = true; $currentHeader = null; @@ -164,7 +164,7 @@ protected function streamCall(string $url, int $timeout = -1): array } $currentData = ''; } else { - $currentHeader['size'] -= \mb_strlen($str); + $currentHeader['size'] -= \strlen($str); $currentData .= $str; $str = ''; } From 00e78059a639a0e1eddbdc0630944f823b9edc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 13 Aug 2024 19:31:43 +0000 Subject: [PATCH 5/5] Fix bug --- src/Orchestration/Adapter/DockerAPI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchestration/Adapter/DockerAPI.php b/src/Orchestration/Adapter/DockerAPI.php index 24be5b7..3504f3c 100644 --- a/src/Orchestration/Adapter/DockerAPI.php +++ b/src/Orchestration/Adapter/DockerAPI.php @@ -153,7 +153,7 @@ protected function streamCall(string $url, int $timeout = -1): array if (\strlen($str) >= $size) { $currentData .= \substr($str, 0, $size); - $str = \strcut($str, $size, null); + $str = \substr($str, $size, null); $isHeader = true; $currentHeader = null;