From a9fec0373edbeb3f6f247bad178f9aab8e6db612 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 5 Mar 2018 19:16:33 +0100 Subject: [PATCH] [BIGUPDATE: api.core.Request] Now the api tries to parse JSON parameters (if cannot, they are considered as text) -> the parsed data is passed to controllers -> the checker uses the parsed data --- build/api/core/Request.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/api/core/Request.php b/build/api/core/Request.php index aadc70a..dce1f28 100755 --- a/build/api/core/Request.php +++ b/build/api/core/Request.php @@ -374,6 +374,13 @@ /* (2) Si le paramètre est renseigné (sauf FILE) */ }elseif( $config['typ'] != 'FILE' ){ + // Try to get json representation + $json_rep = json_decode('{"json": '.$this->raw_params[$name].'}', true); + + // Use only if not failed + if( is_array($json_rep) && isset($json_rep['json']) ) + $this->raw_params[$name] = $json_rep['json']; + // Si la verification est fausse, on retourne faux if( !Checker::run($config['typ'], $this->raw_params[$name]) ) return $this->error->set(Err::WrongParam, $rename, $config['typ']);