File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -730,6 +730,18 @@ function replaceNodeTextFn(
730730 safe . uboLog ( logPrefix , 'Quitting' ) ;
731731 }
732732 } ;
733+ const textContentFactory = ( ( ) => {
734+ const out = { createScript : s => s } ;
735+ const { trustedTypes : tt } = self ;
736+ if ( tt instanceof Object ) {
737+ if ( typeof tt . getPropertyType === 'function' ) {
738+ if ( tt . getPropertyType ( 'script' , 'textContent' ) === 'TrustedScript' ) {
739+ return tt . createPolicy ( 'uBO' , out ) ;
740+ }
741+ }
742+ }
743+ return out ;
744+ } ) ( ) ;
733745 let sedCount = extraArgs . sedCount || 0 ;
734746 const handleNode = node => {
735747 const before = node . textContent ;
@@ -747,7 +759,9 @@ function replaceNodeTextFn(
747759 const after = pattern !== ''
748760 ? before . replace ( rePattern , replacement )
749761 : replacement ;
750- node . textContent = after ;
762+ node . textContent = node . nodeName === 'SCRIPT'
763+ ? textContentFactory . createScript ( after )
764+ : after ;
751765 if ( safe . logLevel > 1 ) {
752766 safe . uboLog ( logPrefix , `Text before:\n${ before . trim ( ) } ` ) ;
753767 }
You can’t perform that action at this time.
0 commit comments