* @ngdoc provider * @name $sceDelegateProvider * @description * * The `$sceDelegateProvider` provider allows developers to configure the ng.$sceDelegate * $sceDelegate service. This allows one to get/set the whitelists and blacklists used to ensure * that the URLs used for sourcing An
()
| 15171 | */ |
| 15172 | |
| 15173 | function $SceDelegateProvider() { |
| 15174 | this.SCE_CONTEXTS = SCE_CONTEXTS; |
| 15175 | |
| 15176 | // Resource URLs can also be trusted by policy. |
| 15177 | var resourceUrlWhitelist = ['self'], |
| 15178 | resourceUrlBlacklist = []; |
| 15179 | |
| 15180 | /** |
| 15181 | * @ngdoc method |
| 15182 | * @name $sceDelegateProvider#resourceUrlWhitelist |
| 15183 | * @kind function |
| 15184 | * |
| 15185 | * @param {Array=} whitelist When provided, replaces the resourceUrlWhitelist with the value |
| 15186 | * provided. This must be an array or null. A snapshot of this array is used so further |
| 15187 | * changes to the array are ignored. |
| 15188 | * |
| 15189 | * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items |
| 15190 | * allowed in this array. |
| 15191 | * |
| 15192 | * Note: **an empty whitelist array will block all URLs**! |
| 15193 | * |
| 15194 | * @return {Array} the currently set whitelist array. |
| 15195 | * |
| 15196 | * The **default value** when no whitelist has been explicitly set is `['self']` allowing only |
| 15197 | * same origin resource requests. |
| 15198 | * |
| 15199 | * @description |
| 15200 | * Sets/Gets the whitelist of trusted resource URLs. |
| 15201 | */ |
| 15202 | this.resourceUrlWhitelist = function(value) { |
| 15203 | if (arguments.length) { |
| 15204 | resourceUrlWhitelist = adjustMatchers(value); |
| 15205 | } |
| 15206 | return resourceUrlWhitelist; |
| 15207 | }; |
| 15208 | |
| 15209 | /** |
| 15210 | * @ngdoc method |
| 15211 | * @name $sceDelegateProvider#resourceUrlBlacklist |
| 15212 | * @kind function |
| 15213 | * |
| 15214 | * @param {Array=} blacklist When provided, replaces the resourceUrlBlacklist with the value |
| 15215 | * provided. This must be an array or null. A snapshot of this array is used so further |
| 15216 | * changes to the array are ignored. |
| 15217 | * |
| 15218 | * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items |
| 15219 | * allowed in this array. |
| 15220 | * |
| 15221 | * The typical usage for the blacklist is to **block |
| 15222 | * [open redirects](http://cwe.mitre.org/data/definitions/601.html)** served by your domain as |
| 15223 | * these would otherwise be trusted but actually return content from the redirected domain. |
| 15224 | * |
| 15225 | * Finally, **the blacklist overrides the whitelist** and has the final say. |
| 15226 | * |
| 15227 | * @return {Array} the currently set blacklist array. |
| 15228 | * |
| 15229 | * The **default value** when no whitelist has been explicitly set is the empty array (i.e. there |
| 15230 | * is no blacklist.) |
nothing calls this directly
no test coverage detected