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 @@ -46,6 +46,25 @@ const defaultElementMethods = {
46
46
}
47
47
const supportedTrustedTypes = 'TrustedScriptURL' in window
48
48
49
+ const jsMimeTypes = [
50
+ 'text/javascript' ,
51
+ 'text/ecmascript' ,
52
+ 'application/javascript' ,
53
+ 'application/ecmascript' ,
54
+ 'application/x-javascript' ,
55
+ 'application/x-ecmascript' ,
56
+ 'text/javascript1.0' ,
57
+ 'text/javascript1.1' ,
58
+ 'text/javascript1.2' ,
59
+ 'text/javascript1.3' ,
60
+ 'text/javascript1.4' ,
61
+ 'text/javascript1.5' ,
62
+ 'text/jscript' ,
63
+ 'text/livescript' ,
64
+ 'text/x-ecmascript' ,
65
+ 'text/x-javascript'
66
+ ]
67
+
49
68
class DDGRuntimeChecks extends HTMLElement {
50
69
#tagName
51
70
#el
@@ -130,6 +149,12 @@ class DDGRuntimeChecks extends HTMLElement {
130
149
// @ts -expect-error TrustedScript is not defined in the TS lib
131
150
if ( supportedTrustedTypes && el . textContent instanceof TrustedScript ) return
132
151
152
+ // Short circuit if not a script type
153
+ const scriptType = el . type . toLowerCase ( )
154
+ if ( ! jsMimeTypes . includes ( scriptType ) &&
155
+ scriptType !== 'module' &&
156
+ scriptType !== '' ) return
157
+
133
158
el . textContent = wrapScriptCodeOverload ( el . textContent , scriptOverload )
134
159
}
135
160
You can’t perform that action at this time.
0 commit comments