Skip to content

Commit fd634a6

Browse files
authored
Fix for #1171 utf-16 issue in SmartSerializer (#1179)
* Fix for #1171 utf-16 issue in smartserializer * Removed recursive call in SmartSerializer::decode
1 parent 3fff30d commit fd634a6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Elasticsearch/Serializers/SmartSerializer.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ private function decode(?string $data): array
8888
} catch (JsonException $e) {
8989
switch ($e->getCode()) {
9090
case JSON_ERROR_UTF16:
91-
return $this->decode(str_replace('\\', '\\\\', $data));
91+
try {
92+
$data = str_replace('\\', '\\\\', $data);
93+
$result = json_decode($data, true, 512, JSON_THROW_ON_ERROR);
94+
return $result;
95+
} catch (JsonException $e) {
96+
throw new JsonErrorException($e->getCode(), $data, $result ?? []);
97+
}
9298
}
9399
throw new JsonErrorException($e->getCode(), $data, $result ?? []);
94100
}

0 commit comments

Comments
 (0)