Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Make Closure Trusted Types integration not require TrustedURL values,…
Browse files Browse the repository at this point in the history
… as they will soon be removed from the Trusted Types API - w3c/trusted-types#204.

goog.createTrustedTypesPolicy will attempt to create a default policy allowing any value to be converted to TrustedURL.

RELNOTES: Trusted Types integrations will allow any value to be a TrustedURL via defensively creating a 'default' policy (to prepare for TrustedURL deprecation)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=264626714
  • Loading branch information
koto authored and nreid260 committed Aug 21, 2019
1 parent 2f43b5f commit 7aa211d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions closure/goog/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4168,6 +4168,21 @@ goog.createTrustedTypesPolicy = function(name) {
} catch (e) {
goog.logToConsole_(e.message);
}

// TrustedTypes API will deprecate TrustedURLs in Chrome 78. To prepare for
// that, and make the Closure code emulate the post-deprecation behavior
// of the API, we attempt to create a default policy that blesses any value
// to TrustedURL. This is a best-effort attempt. If that does not succeed,
// the application fails close - TrustedURL values will simply be required
// at all relevant sinks.
if (typeof TrustedURL !== 'undefined' && TrustedTypes.getPolicyNames &&
TrustedTypes.getPolicyNames().indexOf('default') === -1) {
try {
TrustedTypes.createPolicy('default', {createURL: goog.identity_}, true);
} catch (e) {
goog.logToConsole_(e.message);
}
}
return policy;
};

Expand Down

0 comments on commit 7aa211d

Please sign in to comment.