javascript - CSP unsafe-eval using Google Maps API -
getting script-src
'unsafe-eval'
error when trying use google maps' api.
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
here's console error:
uncaught evalerror: refused evaluate string javascript because 'unsafe-eval' not allowed source of script in following content security policy directive: "script-src 'self' ' *.gstatic.com *.googleapis.com *.google-analytics.com *.google.com".
you think google wouldn't have unsafe-eval triggers in libraries. incase side code below:
js
function initialize() { // create map. var mapoptions = { zoom: 4, center: new google.maps.latlng(37.09024, -95.712891), maptypeid: google.maps.maptypeid.roadmap, zoomcontrol: true, streetviewcontrol: false }; var map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); google.maps.event.addlistener(map, "click", function (e) { var marker = new google.maps.marker({ draggable: true, raiseondrag: false, map: map, position: e.latlng }); var radius = math.pow(2, (20 - map.getzoom())) * 3; if (radius < 100) { radius = 100; } var circle = new google.maps.circle({ map: map, editable: true, radius: radius, fillcolor: '#0159e5', strokecolor: '#0159e5', strokeweight: 1, geodesic: true }); circle.bindto('center', marker, 'position'); google.maps.event.addlistener(circle, 'radius_changed', function() { if (circle.getradius() < 100){ circle.setradius(100); } }); //set form fields document.getelementbyid("geo-fence-lat").value = marker.getposition().lat(); document.getelementbyid("geo-fence-long").value = marker.getposition().lng(); document.getelementbyid("geo-fence-radius").value = math.ceil(radius/100)*100; google.maps.event.clearlisteners(map, "click"); addlisteners(circle); }); }
any fixes or ideas gmaps alternatives appreciated.
edit: these offending lines in chrome. found in maps.gstatic.com maps-api-v3/api/js/21/2/main.js.
kh.main = function(a) { eval(a) }; fg("main", {}); function ql(a) { return o(eval, k, "window." + + "()") }
looks it's been mostly fixed in google maps 3.23 - see issue 4201
there still instances of eval
in code - eval('document.namespaces')
inside of try
blocks (see: related closure fix)
Comments
Post a Comment