fix: failing when request is empty json object

pull/86/head
Luciano Righetti 2022-01-25 18:02:41 +01:00
parent 5da61f15dd
commit d18471ba95
1 changed files with 1 additions and 1 deletions

View File

@ -48,7 +48,7 @@ class ParamHandlerComponent extends Component
return $this->isRest;
}
if ($this->request->is('json')) {
if (!empty((string)$this->request->getBody()) && empty($this->request->getParsedBody())) {
if (!empty((string)$this->request->getBody()) && !is_array($this->request->getParsedBody())) {
throw new MethodNotAllowedException('Invalid JSON input. Make sure that the JSON input is a correctly formatted JSON string. This request has been blocked to avoid an unfiltered request.');
}
$this->isRest = true;