mozfreddyb / domsnitch

Automatically exported from code.google.com/p/domsnitch
Apache License 2.0
5 stars 0 forks source link

eval does not execute within the proper context when hooked #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Enable win.eval hook
2. Execute evel within the context of a function, not a window, and reference 
variables that are only valid within the function context

What is the expected output? What do you see instead?

eval command should work

What version of the product are you using? On what operating system?

eval is executed within the context of the window

Please provide any additional information below.

function x() {
  var y = 1;

  try {
    eval("y++");
  } catch(e) {}
}
var z = new x();

Not sure if the try/catch block or function creation matters.

Original issue reported on code.google.com by megazzt on 22 Jun 2011 at 3:07

GoogleCodeExporter commented 8 years ago
Aaand I didn't read the section headers when filling them in, sorry.  Still on 
0.706

Original comment by megazzt on 22 Jun 2011 at 3:08

GoogleCodeExporter commented 8 years ago
Hi, this is a known issue due to eval having some magic properties with respect 
to scope. I've written a bit more detailed blog post on the topic here: 
http://radi.r-n-d.org/2011/02/evil-magic-of-eval.html

Original comment by rad...@gmail.com on 22 Jun 2011 at 6:14

GoogleCodeExporter commented 8 years ago
Ew yeah I get that; I actually noticed some of that myself when working with 
eval() (I do not use it myself, but it seems some of my coworkers are fond of 
it).

I think I even tried to override the context of eval once and realized I 
couldn't do it.

What you guys need to do is write a JS engine in JS and then use it for eval(). 
;)  Problem solved!

Original comment by megazzt on 23 Jun 2011 at 7:13

GoogleCodeExporter commented 8 years ago
Writing a new JS engine might be an overkill for this task. I'll mark it as 
accepted for now, but don't guarantee quick resolution. 

Original comment by r...@google.com on 6 Jul 2011 at 2:29