mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°2198 ReloadBlock call and parameter escaping improvements
Use an anonymous function instead of a string to get rid of a useless level of escaping Use json_encode instead of addslashes (many thanks for the tips @bruno-ds !!)
This commit is contained in:
@@ -1173,8 +1173,10 @@ EOF
|
|||||||
if (($bAutoReload) && ($this->m_sStyle != 'search')) // Search form do NOT auto-reload
|
if (($bAutoReload) && ($this->m_sStyle != 'search')) // Search form do NOT auto-reload
|
||||||
{
|
{
|
||||||
// Used either for asynchronous or auto_reload
|
// Used either for asynchronous or auto_reload
|
||||||
$sFilter = addslashes(str_replace("'", "\'", $this->m_oFilter->serialize()));
|
// does a json_encode twice to get a string usable as function parameter
|
||||||
$sExtraParams = addslashes(str_replace("'", "\'", json_encode($aExtraParams)));
|
$sFilterBefore = $this->m_oFilter->serialize();
|
||||||
|
$sFilter = json_encode($sFilterBefore);
|
||||||
|
$sExtraParams = json_encode(json_encode($aExtraParams));
|
||||||
|
|
||||||
$oPage->add_script(
|
$oPage->add_script(
|
||||||
<<<JS
|
<<<JS
|
||||||
@@ -1184,7 +1186,10 @@ if (typeof window.oAutoReloadBlock == "undefined") {
|
|||||||
if (typeof window.oAutoReloadBlock['$sId'] != "undefined") {
|
if (typeof window.oAutoReloadBlock['$sId'] != "undefined") {
|
||||||
clearInterval(window.oAutoReloadBlock['$sId']);
|
clearInterval(window.oAutoReloadBlock['$sId']);
|
||||||
}
|
}
|
||||||
window.oAutoReloadBlock['$sId'] = setInterval("ReloadBlock('$sId', '{$this->m_sStyle}', '$sFilter', '$sExtraParams')", '$iReloadInterval');
|
|
||||||
|
window.oAutoReloadBlock['$sId'] = setInterval(function() {
|
||||||
|
ReloadBlock('$sId', '{$this->m_sStyle}', $sFilter, $sExtraParams);
|
||||||
|
}, '$iReloadInterval');
|
||||||
JS
|
JS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user