MCPcopy Create free account
hub / github.com/angular-ui/ui-router / csp

Function csp

test/angular/1.4/angular.js:1091–1125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1089}
1090
1091var csp = function() {
1092 if (!isDefined(csp.rules)) {
1093
1094
1095 var ngCspElement = (document.querySelector('[ng-csp]') ||
1096 document.querySelector('[data-ng-csp]'));
1097
1098 if (ngCspElement) {
1099 var ngCspAttribute = ngCspElement.getAttribute('ng-csp') ||
1100 ngCspElement.getAttribute('data-ng-csp');
1101 csp.rules = {
1102 noUnsafeEval: !ngCspAttribute || (ngCspAttribute.indexOf('no-unsafe-eval') !== -1),
1103 noInlineStyle: !ngCspAttribute || (ngCspAttribute.indexOf('no-inline-style') !== -1)
1104 };
1105 } else {
1106 csp.rules = {
1107 noUnsafeEval: noUnsafeEval(),
1108 noInlineStyle: false
1109 };
1110 }
1111 }
1112
1113 return csp.rules;
1114
1115 function noUnsafeEval() {
1116 try {
1117 /* jshint -W031, -W054 */
1118 new Function('');
1119 /* jshint +W031, +W054 */
1120 return false;
1121 } catch (e) {
1122 return true;
1123 }
1124 }
1125};
1126
1127/**
1128 * @ngdoc directive

Callers 2

$ParseProviderFunction · 0.70
$SnifferProviderFunction · 0.70

Calls 2

isDefinedFunction · 0.70
noUnsafeEvalFunction · 0.70

Tested by

no test coverage detected