Skip to content

Commit

Permalink
Add exception to json_decode
Browse files Browse the repository at this point in the history
  • Loading branch information
joanhey committed Jan 5, 2024
1 parent 1e06a53 commit 441a434
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public static function decode(string $recv_buffer, TcpConnection $connection): v
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER['CONTENT_TYPE']) {
match ($_SERVER['CONTENT_TYPE']) {
'multipart/form-data' => static::parseMultipart($http_body, $http_post_boundary),
'application/json' => $_POST = \json_decode($http_body, true) ?? [],
'application/json' => $_POST = \json_decode($http_body, true, flags: \JSON_THROW_ON_ERROR) ?? [],
'application/x-www-form-urlencoded' => \parse_str($http_body, $_POST),
default => ''
};
Expand All @@ -415,7 +415,7 @@ public static function decode(string $recv_buffer, TcpConnection $connection): v
$data = [];
match ($_SERVER['CONTENT_TYPE']) {
'application/x-www-form-urlencoded' => \parse_str($http_body, $data),
'application/json' => $data = \json_decode($http_body, true) ?? [],
'application/json' => $data = \json_decode($http_body, true, flags: \JSON_THROW_ON_ERROR) ?? [],
default => ''
};
$_REQUEST = $data;
Expand Down

0 comments on commit 441a434

Please sign in to comment.