()
| 1057 | } |
| 1058 | |
| 1059 | var 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 |
no test coverage detected