From bd2a9c6f45648a858585816e0200536aa7196670 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 17 Jul 2014 17:26:25 +0000 Subject: [PATCH] fix an other CSP error, caused by json-responses send eg. from get_rows method on a GET request, filemanager opened in iframe from tracker --- etemplate/inc/class.etemplate_new.inc.php | 22 +++++++++++----------- phpgwapi/inc/class.egw_json.inc.php | 19 +++++++++++++++++++ phpgwapi/js/jsapi/egw.js | 5 +++++ 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/etemplate/inc/class.etemplate_new.inc.php b/etemplate/inc/class.etemplate_new.inc.php index 92e458c634..1cd672db93 100644 --- a/etemplate/inc/class.etemplate_new.inc.php +++ b/etemplate/inc/class.etemplate_new.inc.php @@ -216,6 +216,17 @@ class etemplate_new extends etemplate_widget_template { echo '
'."\n"; } + // Send any accumulated json responses - after flush to avoid sending the buffer as a response + if(egw_json_response::isJSONResponse()) + { + $load_array['response'] = egw_json_response::get()->returnResult(); + /*$response = egw_json_response::get(); + echo '';*/ + } echo '
'; if ($output_mode == 2) @@ -224,17 +235,6 @@ class etemplate_new extends etemplate_widget_template echo $GLOBALS['egw']->framework->footer(); } ob_flush(); - - // Send any accumulated json responses - after flush to avoid sending the buffer as a response - if(egw_json_response::isJSONResponse()) - { - $response = egw_json_response::get(); - echo ''; - } } self::$request = null; } diff --git a/phpgwapi/inc/class.egw_json.inc.php b/phpgwapi/inc/class.egw_json.inc.php index aa35fcf1e9..2feedebe04 100644 --- a/phpgwapi/inc/class.egw_json.inc.php +++ b/phpgwapi/inc/class.egw_json.inc.php @@ -284,6 +284,25 @@ class egw_json_response $inst->initResponseArray(); } + /** + * Return json response data, after running beforeSendDataProcs + * + * Used to send json response with etemplate data in GET request + * + * @return array responseArray + */ + public static function returnResult() + { + $inst = self::get(); + + //Call each attached before send data proc + foreach ($inst->beforeSendDataProcs as $proc) + { + call_user_func_array($proc['proc'], $proc['params']); + } + return $inst->initResponseArray(); + } + /** * xAjax compatibility function */ diff --git a/phpgwapi/js/jsapi/egw.js b/phpgwapi/js/jsapi/egw.js index 16868063f3..3caf158ee8 100644 --- a/phpgwapi/js/jsapi/egw.js +++ b/phpgwapi/js/jsapi/egw.js @@ -227,6 +227,11 @@ } var et2 = new etemplate2(node, currentapp+".etemplate_new.ajax_process_content.etemplate"); et2.load(data.name,data.url,data.data); + if (typeof data.response != 'undefined') + { + var json_request = egw(window).json(); + json_request.handleResponse({response: data.response}); + } }); $j(function() {