fix: incorrect check

pull/80/head
Luciano Righetti 2022-01-10 11:59:23 +01:00
parent 28650fa91c
commit ce1a51cc39
1 changed files with 2 additions and 1 deletions

View File

@ -4,6 +4,7 @@ namespace App\Controller\Component;
use Cake\Controller\Component; use Cake\Controller\Component;
use Cake\Core\Configure; use Cake\Core\Configure;
use Cake\Http\Exception\MethodNotAllowedException;
class ParamHandlerComponent extends Component class ParamHandlerComponent extends Component
{ {
@ -47,7 +48,7 @@ class ParamHandlerComponent extends Component
return $this->isRest; return $this->isRest;
} }
if ($this->request->is('json')) { if ($this->request->is('json')) {
if (!empty($this->request->getBody()) && !empty($this->request->getParsedBody())) { if (!empty((string)$this->request->getBody()) && empty($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.'); 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; $this->isRest = true;