Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Nov 13, 2015 · 4 comments
Open

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

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 [email protected] on 22 Jun 2011 at 6:14

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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 [email protected] on 6 Jul 2011 at 2:29

  • Changed state: Accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant