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

Function $SceDelegateProvider

test/angular/1.6/angular.js:19472–19737  ·  view source on GitHub ↗

* @ngdoc provider * @name $sceDelegateProvider * @this * * @description * * The `$sceDelegateProvider` provider allows developers to configure the ng.$sceDelegate * $sceDelegate service, used as a delegate for ng.$sce Strict Contextual Escaping (SCE). * * The `$sceDelegatePr

()

Source from the content-addressed store, hash-verified

19470 */
19471
19472function $SceDelegateProvider() {
19473 this.SCE_CONTEXTS = SCE_CONTEXTS;
19474
19475 // Resource URLs can also be trusted by policy.
19476 var resourceUrlWhitelist = ['self'],
19477 resourceUrlBlacklist = [];
19478
19479 /**
19480 * @ngdoc method
19481 * @name $sceDelegateProvider#resourceUrlWhitelist
19482 * @kind function
19483 *
19484 * @param {Array=} whitelist When provided, replaces the resourceUrlWhitelist with the value
19485 * provided. This must be an array or null. A snapshot of this array is used so further
19486 * changes to the array are ignored.
19487 * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items
19488 * allowed in this array.
19489 *
19490 * @return {Array} The currently set whitelist array.
19491 *
19492 * @description
19493 * Sets/Gets the whitelist of trusted resource URLs.
19494 *
19495 * The **default value** when no whitelist has been explicitly set is `['self']` allowing only
19496 * same origin resource requests.
19497 *
19498 * <div class="alert alert-warning">
19499 * **Note:** the default whitelist of 'self' is not recommended if your app shares its origin
19500 * with other apps! It is a good idea to limit it to only your application's directory.
19501 * </div>
19502 */
19503 this.resourceUrlWhitelist = function(value) {
19504 if (arguments.length) {
19505 resourceUrlWhitelist = adjustMatchers(value);
19506 }
19507 return resourceUrlWhitelist;
19508 };
19509
19510 /**
19511 * @ngdoc method
19512 * @name $sceDelegateProvider#resourceUrlBlacklist
19513 * @kind function
19514 *
19515 * @param {Array=} blacklist When provided, replaces the resourceUrlBlacklist with the value
19516 * provided. This must be an array or null. A snapshot of this array is used so further
19517 * changes to the array are ignored.</p><p>
19518 * Follow {@link ng.$sce#resourceUrlPatternItem this link} for a description of the items
19519 * allowed in this array.</p><p>
19520 * The typical usage for the blacklist is to **block
19521 * [open redirects](http://cwe.mitre.org/data/definitions/601.html)** served by your domain as
19522 * these would otherwise be trusted but actually return content from the redirected domain.
19523 * </p><p>
19524 * Finally, **the blacklist overrides the whitelist** and has the final say.
19525 *
19526 * @return {Array} The currently set blacklist array.
19527 *
19528 * @description
19529 * Sets/Gets the blacklist of trusted resource URLs.

Callers

nothing calls this directly

Calls 2

adjustMatchersFunction · 0.70
generateHolderTypeFunction · 0.70

Tested by

no test coverage detected