File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,19 @@ Object.keys(descs).forEach((key) => {
135
135
export function proxyContext ( global : any , context : any ) {
136
136
const special = Object . assign ( writables ) ;
137
137
// 后台脚本要不要考虑不能使用eval?
138
- const thisContext : { [ key : string ] : any } = { eval : global . eval } ;
138
+ const thisContext : { [ key : string ] : any } = {
139
+ eval : global . eval ,
140
+ } ;
141
+ // keyword是与createContext时同步的,避免访问到context的内部变量
142
+ const contextKeyword : { [ key : string ] : any } = {
143
+ message : 1 ,
144
+ valueChangeListener : 1 ,
145
+ connect : 1 ,
146
+ runFlag : 1 ,
147
+ valueUpdate : 1 ,
148
+ sendMessage : 1 ,
149
+ scriptRes : 1 ,
150
+ } ;
139
151
// @ts -ignore
140
152
const proxy = new Proxy ( context , {
141
153
defineProperty ( _ , name , desc ) {
@@ -167,6 +179,9 @@ export function proxyContext(global: any, context: any) {
167
179
return thisContext [ name ] ;
168
180
}
169
181
if ( context [ name ] ) {
182
+ if ( contextKeyword [ name ] ) {
183
+ return undefined ;
184
+ }
170
185
return context [ name ] ;
171
186
}
172
187
if ( special [ name ] !== undefined ) {
@@ -210,9 +225,9 @@ export function proxyContext(global: any, context: any) {
210
225
return true ;
211
226
}
212
227
if ( context [ name ] ) {
213
- return true ;
214
- }
215
- if ( thisContext [ name ] ) {
228
+ if ( contextKeyword [ name ] ) {
229
+ return false ;
230
+ }
216
231
return true ;
217
232
}
218
233
if ( special [ name ] !== undefined ) {
You can’t perform that action at this time.
0 commit comments