From 768176c5c3c608548e543bfb761c858834a23cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=B3na=20Lore?= Date: Sun, 12 Feb 2017 21:55:46 +0100 Subject: [PATCH] Fix for inline editing. --- e107_handlers/e_parse_class.php | 14 +++++++++++++- e107_handlers/form_handler.php | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 7e1b09d78..41d66eb6d 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -2171,9 +2171,15 @@ class e_parse extends e_parser * We use HTML-safe strings, with several characters escaped. * * @param mixed $var + * PHP variable. + * @param bool $force_object + * True: Outputs an object rather than an array when a non-associative + * array is used. Especially useful when the recipient of the output + * is expecting an object and the array is empty. + * * @return string */ - public function toJSON($var) + public function toJSON($var, $force_object = false) { // The PHP version cannot change within a request. static $php530; @@ -2185,6 +2191,12 @@ class e_parse extends e_parser if($php530) { + if($force_object === true) + { + // Encode <, >, ', &, and " using the json_encode() options parameter. + return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_FORCE_OBJECT); + } + // Encode <, >, ', &, and " using the json_encode() options parameter. return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index a154522f9..41fe81fd7 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -3919,7 +3919,7 @@ class e_form } } - $source = e107::getParser()->toJSON($jsonArray); + $source = e107::getParser()->toJSON($jsonArray, true); $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));