File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ const _createTrustedTypesPolicy = function (trustedTypes, document) {
5555 createHTML ( html ) {
5656 return html ;
5757 } ,
58+ createScriptURL ( scriptUrl ) {
59+ return scriptUrl ;
60+ } ,
5861 } ) ;
5962 } catch ( _ ) {
6063 // Policy creation failed (most likely another DOMPurify script has
@@ -1202,6 +1205,28 @@ function createDOMPurify(window = getGlobal()) {
12021205 continue ;
12031206 }
12041207
1208+ /* Handle attributes that require Trusted Types */
1209+ if (
1210+ trustedTypesPolicy &&
1211+ typeof trustedTypes === 'object' &&
1212+ typeof trustedTypes . getAttributeType === 'function'
1213+ ) {
1214+ if ( namespaceURI ) {
1215+ /* Namespaces are not yet supported, see https://bugs.chromium.org/p/chromium/issues/detail?id=1305293 */
1216+ } else {
1217+ switch ( trustedTypes . getAttributeType ( lcTag , lcName ) ) {
1218+ case 'TrustedHTML' :
1219+ value = trustedTypesPolicy . createHTML ( value ) ;
1220+ break ;
1221+ case 'TrustedScriptURL' :
1222+ value = trustedTypesPolicy . createScriptURL ( value ) ;
1223+ break ;
1224+ default :
1225+ break ;
1226+ }
1227+ }
1228+ }
1229+
12051230 /* Handle invalid data-* attribute set by try-catching it */
12061231 try {
12071232 if ( namespaceURI ) {
You can’t perform that action at this time.
0 commit comments