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

This commit is contained in:
Ralf Becker 2014-07-17 17:26:00 +00:00
parent cb35a10b4c
commit f49bbab26f
3 changed files with 35 additions and 11 deletions

View File

@ -216,6 +216,17 @@ class etemplate_new extends etemplate_widget_template
{
echo '<div id="popupMainDiv">'."\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 '<script>egw_LAB.wait(function() {var json = egw.json(); json.handleResponse(';
ob_flush();
$response->sendResult();
unset($response);
echo ')});</script>';*/
}
echo '<div id="'.$dom_id.'" class="et2_container" data-etemplate="'.html::htmlspecialchars(json_encode($load_array), true).'"></div>';
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 '<script>egw_LAB.wait(function() {var json = egw.json(); json.handleResponse(';
ob_flush();
$response->sendResult();
unset($response);
echo ')});</script>';
}
}
self::$request = null;
}

View File

@ -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
*/

View File

@ -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() {