@@ -81,6 +81,15 @@ const makeConfig = ({
81
81
find : / ' _ _ C I T A T I O N S _ _ ' / g,
82
82
replace : JSON . stringify ( citationData , null , 2 ) ,
83
83
} ) ,
84
+ modify ( {
85
+ // Patch to mitigate DOM Clobbering vulnerability
86
+ find : / d o c u m e n t \. c u r r e n t S c r i p t / g,
87
+ replace : `(typeof document !== 'undefined' &&
88
+ document.currentScript &&
89
+ document.currentScript.tagName &&
90
+ document.currentScript.tagName.toUpperCase() === 'SCRIPT' &&
91
+ document.currentScript)` ,
92
+ } ) ,
84
93
esbuild ( { ...esBuildPluginOptions , target : "node18" } ) ,
85
94
commonjs ( commonjsPluginOptions ) ,
86
95
] ,
@@ -111,6 +120,15 @@ const makeConfig = ({
111
120
find : / ' _ _ C I T A T I O N S _ _ ' / g,
112
121
replace : JSON . stringify ( citationData , null , 2 ) ,
113
122
} ) ,
123
+ modify ( {
124
+ // Patch to mitigate DOM Clobbering vulnerability
125
+ find : / d o c u m e n t \. c u r r e n t S c r i p t / g,
126
+ replace : `(typeof document !== 'undefined' &&
127
+ document.currentScript &&
128
+ document.currentScript.tagName &&
129
+ document.currentScript.tagName.toUpperCase() === 'SCRIPT' &&
130
+ document.currentScript)` ,
131
+ } ) ,
114
132
resolve ( { preferBuiltins : false } ) ,
115
133
esbuild ( { ...esBuildPluginOptions , target : "esnext" } ) ,
116
134
commonjs ( commonjsPluginOptions ) ,
@@ -135,6 +153,15 @@ const makeConfig = ({
135
153
find : / ' _ _ C I T A T I O N S _ _ ' / g,
136
154
replace : JSON . stringify ( citationData , null , 2 ) ,
137
155
} ) ,
156
+ modify ( {
157
+ // Patch to mitigate DOM Clobbering vulnerability
158
+ find : / d o c u m e n t \. c u r r e n t S c r i p t / g,
159
+ replace : `(typeof document !== 'undefined' &&
160
+ document.currentScript &&
161
+ document.currentScript.tagName &&
162
+ document.currentScript.tagName.toUpperCase() === 'SCRIPT' &&
163
+ document.currentScript)` ,
164
+ } ) ,
138
165
resolve ( { preferBuiltins : false } ) ,
139
166
esbuild ( { ...esBuildPluginOptions , target : "es2015" , minify : true } ) ,
140
167
commonjs ( commonjsPluginOptions ) ,
0 commit comments