MCPcopy
hub / github.com/angular-ui/ui-router / csp

Function csp

test/angular/1.7/angular.js:1264–1297  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1262}
1263
1264var csp = function() {
1265 if (!isDefined(csp.rules)) {
1266
1267
1268 var ngCspElement = (window.document.querySelector('[ng-csp]') ||
1269 window.document.querySelector('[data-ng-csp]'));
1270
1271 if (ngCspElement) {
1272 var ngCspAttribute = ngCspElement.getAttribute('ng-csp') ||
1273 ngCspElement.getAttribute('data-ng-csp');
1274 csp.rules = {
1275 noUnsafeEval: !ngCspAttribute || (ngCspAttribute.indexOf('no-unsafe-eval') !== -1),
1276 noInlineStyle: !ngCspAttribute || (ngCspAttribute.indexOf('no-inline-style') !== -1)
1277 };
1278 } else {
1279 csp.rules = {
1280 noUnsafeEval: noUnsafeEval(),
1281 noInlineStyle: false
1282 };
1283 }
1284 }
1285
1286 return csp.rules;
1287
1288 function noUnsafeEval() {
1289 try {
1290 // eslint-disable-next-line no-new, no-new-func
1291 new Function('');
1292 return false;
1293 } catch (e) {
1294 return true;
1295 }
1296 }
1297};
1298
1299/**
1300 * @ngdoc directive

Callers 2

$ParseProviderFunction · 0.70
$SnifferProviderFunction · 0.70

Calls 2

isDefinedFunction · 0.70
noUnsafeEvalFunction · 0.70

Tested by

no test coverage detected