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

Function getTrusted

test/angular/1.3/angular.js:15390–15413  ·  view source on GitHub ↗

* @ngdoc method * @name $sceDelegate#getTrusted * * @description * Takes the result of a ng.$sceDelegate#trustAs `$sceDelegate.trustAs` call and * returns the originally supplied value if the queried context type is a supertype of the * created type. If this co

(type, maybeTrusted)

Source from the content-addressed store, hash-verified

15388 * `$sceDelegate.trustAs`} if valid in this context. Otherwise, throws an exception.
15389 */
15390 function getTrusted(type, maybeTrusted) {
15391 if (maybeTrusted === null || maybeTrusted === undefined || maybeTrusted === '') {
15392 return maybeTrusted;
15393 }
15394 var constructor = (byType.hasOwnProperty(type) ? byType[type] : null);
15395 if (constructor && maybeTrusted instanceof constructor) {
15396 return maybeTrusted.$$unwrapTrustedValue();
15397 }
15398 // If we get here, then we may only take one of two actions.
15399 // 1. sanitize the value for the requested type, or
15400 // 2. throw an exception.
15401 if (type === SCE_CONTEXTS.RESOURCE_URL) {
15402 if (isResourceUrlAllowedByPolicy(maybeTrusted)) {
15403 return maybeTrusted;
15404 } else {
15405 throw $sceMinErr('insecurl',
15406 'Blocked loading resource from url not allowed by $sceDelegate policy. URL: {0}',
15407 maybeTrusted.toString());
15408 }
15409 } else if (type === SCE_CONTEXTS.HTML) {
15410 return htmlSanitizer(maybeTrusted);
15411 }
15412 throw $sceMinErr('unsafe', 'Attempting to use an unsafe value in a safe context.');
15413 }
15414
15415 return { trustAs: trustAs,
15416 getTrusted: getTrusted,

Callers 1

$SceProviderFunction · 0.70

Calls 2

htmlSanitizerFunction · 0.70

Tested by

no test coverage detected