From cf9e6a62ad212484e78adb71e2a311e7a7782bb0 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 15 Aug 2018 13:10:15 +0200 Subject: [PATCH] allow to process real JSON requests with Content-Type: application/json so far we always send it encoded as form, which is still supported of cause --- json.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/json.php b/json.php index 276d7b7542..4410cf702f 100644 --- a/json.php +++ b/json.php @@ -7,7 +7,6 @@ * @package api * @subpackage ajax * @author Andreas Stoeckel - * @version $Id$ */ use EGroupware\Api; @@ -116,7 +115,15 @@ if (isset($_GET['menuaction'])) $json->isJSONRequest(true); // otherwise exception is not send back to client, as we have not yet called parseRequest() throw new Json\Exception\ScriptTags("JSON Data contains script tags. Aborting..."); } - $json->parseRequest($_GET['menuaction'], $_REQUEST['json_data']); + // check if we have a real json request + if (strpos($_SERVER['CONTENT_TYPE'], 'application/json') === 0) + { + $json->parseRequest($_GET['menuaction'], file_get_contents('php://input')); + } + else + { + $json->parseRequest($_GET['menuaction'], $_REQUEST['json_data']); + } Json\Response::get(); exit(); }