File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,25 @@ const defaultElementMethods = {
44
44
}
45
45
const supportedTrustedTypes = 'TrustedScriptURL' in window
46
46
47
+ const jsMimeTypes = [
48
+ 'text/javascript' ,
49
+ 'text/ecmascript' ,
50
+ 'application/javascript' ,
51
+ 'application/ecmascript' ,
52
+ 'application/x-javascript' ,
53
+ 'application/x-ecmascript' ,
54
+ 'text/javascript1.0' ,
55
+ 'text/javascript1.1' ,
56
+ 'text/javascript1.2' ,
57
+ 'text/javascript1.3' ,
58
+ 'text/javascript1.4' ,
59
+ 'text/javascript1.5' ,
60
+ 'text/jscript' ,
61
+ 'text/livescript' ,
62
+ 'text/x-ecmascript' ,
63
+ 'text/x-javascript'
64
+ ]
65
+
47
66
class DDGRuntimeChecks extends HTMLElement {
48
67
#tagName
49
68
#el
@@ -128,6 +147,12 @@ class DDGRuntimeChecks extends HTMLElement {
128
147
// @ts -expect-error TrustedScript is not defined in the TS lib
129
148
if ( supportedTrustedTypes && el . textContent instanceof TrustedScript ) return
130
149
150
+ // Short circuit if not a script type
151
+ const scriptType = el . type . toLowerCase ( )
152
+ if ( ! jsMimeTypes . includes ( scriptType ) &&
153
+ scriptType !== 'module' &&
154
+ scriptType !== '' ) return
155
+
131
156
el . textContent = wrapScriptCodeOverload ( el . textContent , scriptOverload )
132
157
}
133
158
You can’t perform that action at this time.
0 commit comments