MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / csp

Function csp

web/static/bower_components/angular/angular.js:1059–1093  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1057}
1058
1059var csp = function() {
1060 if (!isDefined(csp.rules)) {
1061
1062
1063 var ngCspElement = (document.querySelector('[ng-csp]') ||
1064 document.querySelector('[data-ng-csp]'));
1065
1066 if (ngCspElement) {
1067 var ngCspAttribute = ngCspElement.getAttribute('ng-csp') ||
1068 ngCspElement.getAttribute('data-ng-csp');
1069 csp.rules = {
1070 noUnsafeEval: !ngCspAttribute || (ngCspAttribute.indexOf('no-unsafe-eval') !== -1),
1071 noInlineStyle: !ngCspAttribute || (ngCspAttribute.indexOf('no-inline-style') !== -1)
1072 };
1073 } else {
1074 csp.rules = {
1075 noUnsafeEval: noUnsafeEval(),
1076 noInlineStyle: false
1077 };
1078 }
1079 }
1080
1081 return csp.rules;
1082
1083 function noUnsafeEval() {
1084 try {
1085 /* jshint -W031, -W054 */
1086 new Function('');
1087 /* jshint +W031, +W054 */
1088 return false;
1089 } catch (e) {
1090 return true;
1091 }
1092 }
1093};
1094
1095/**
1096 * @ngdoc directive

Callers 2

$ParseProviderFunction · 0.85
$SnifferProviderFunction · 0.85

Calls 2

isDefinedFunction · 0.85
noUnsafeEvalFunction · 0.85

Tested by

no test coverage detected