Skip to content

Commit

Permalink
Fix critical issue with incorrect json decode
Browse files Browse the repository at this point in the history
  • Loading branch information
donhardman committed May 18, 2021
1 parent 6bdc781 commit 43dd1fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ protected function requestDecode(string $response): mixed {
return match ($this->request_type) {
'msgpack' => msgpack_unpack($response),
// This hack is needed to prevent converting numbers like 1.3 to 1.2999999999 cuz PHP is shit in this case
'json' => json_decode($response = preg_replace('/"\s*:\s*([0-9]+\.[0-9]+)([,\}\]])/ius', '":"$1$2"', $response), true, flags: JSON_BIGINT_AS_STRING),
'json' => json_decode($response = preg_replace('/"\s*:\s*([0-9]+\.[0-9]+)([,\}\]])/ius', '":"$1"$2', $response), true, flags: JSON_BIGINT_AS_STRING),
'binary' => BinaryCodec::create()->unpack($response),
default => $response,
};
Expand Down

0 comments on commit 43dd1fc

Please sign in to comment.