Hi Jan,
I am trying to get rid of 'unsafe-eval' in my CSP. It is just the map that is still needing it.
I had a look at it and found out that it is not Google Maps itself that needs the attribute but a function in the Phoca Maps Helper (phocamapsmap.php).
I changed the function as follows:
function setInitializeFunctionSpecificMap() {
$js = 'function initMap'.$this->_id.'() {'."\n"
.' '.$this->_tst.'.setAttribute("oldValue'.$this->_id.'",0);'."\n"
.' '.$this->_tst.'.setAttribute("refreshMap'.$this->_id.'",0);'."\n"
// .' '.$this->_tstint.' = setInterval("CheckPhocaMap'.$this->_id.'()",500);'."\n"
.' '.$this->_tstint.' = setInterval(CheckPhocaMap'.$this->_id.',500);'."\n"
.'}'."\n";
return $js;
}
And now the map is loading without unsafe-eval. I don't want to make a core override of the component. Do you think you can change that in the helper?
Both forms are functionally identical: passing a string makes the browser parse and evaluate it as JavaScript on every tick, whereas passing the function reference calls the exact same function directly — same result, minus the eval step that CSP blocks.
The reference resolves reliably because CheckPhocaMap<ID> is a hoisted function declaration in the same script block, so it is defined before initMap<ID>() ever runs.
Kind regards, Tanja
Change function to load map to get rid of unsafe-eval
-
Picannick
- Phoca Member

- Posts: 19
- Joined: 10 May 2013, 15:50
- Contact: