@@ -5,7 +5,7 @@ let replaceGlobalMeter;
5
5
6
6
// When using this function's text in a SES-1.0 shim, we redefine this
7
7
// constant to be Error.
8
- const SES1ErrorConstructor = Error ;
8
+ const SES1ErrorConstructor = null ;
9
9
10
10
export function tameMetering ( ) {
11
11
if ( replaceGlobalMeter ) {
@@ -34,6 +34,9 @@ export function tameMetering() {
34
34
const setWrapped = ( ...args ) => apply ( wmSet , wrapped , args ) ;
35
35
const getWrapped = ( ...args ) => apply ( wmGet , wrapped , args ) ;
36
36
37
+ // eslint-disable-next-line no-new-func
38
+ const globalEval = Function ( 'return eval' ) ( ) ;
39
+
37
40
// How to test for a constructor: https://stackoverflow.com/a/48036194
38
41
const isConstructorHandler = {
39
42
construct ( ) {
@@ -76,7 +79,8 @@ export function tameMetering() {
76
79
if (
77
80
typeof target !== 'function' ||
78
81
target === FunctionPrototype ||
79
- target === SES1ErrorConstructor
82
+ target === SES1ErrorConstructor ||
83
+ target === globalEval
80
84
) {
81
85
// Preserve identity and mutate in place.
82
86
wrapper = target ;
@@ -142,6 +146,9 @@ export function tameMetering() {
142
146
( { [ name ] : wrapper } = {
143
147
[ name ] ( ...args ) {
144
148
// Fast path:
149
+ if ( name === 'eval' ) {
150
+ console . log ( 'eval escaped' , target ) ;
151
+ }
145
152
if ( ! globalMeter ) {
146
153
return apply ( target , this , args ) ;
147
154
}
0 commit comments