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

new Function(s) can be broken with regexps #165

Open
robotlolita opened this issue Dec 11, 2014 · 1 comment
Open

new Function(s) can be broken with regexps #165

robotlolita opened this issue Dec 11, 2014 · 1 comment

Comments

@robotlolita
Copy link
Contributor

So, I just noticed old v8's didn't follow the new Function specs and decided to review my Higgs' patch, and discovered you can break it with:

new Function("/{{/; }; x = 'evil'; /}/; function(){"); 

This should create a global x variable because the code counts the brackets inside regexps for balancing. Well, it should do that, but I just get an endless stream of GC instead:

$ ./higgs
Entering read-eval-print loop
To exit, press Ctrl+D (end-of-file) or type "exit" at the prompt
h> new Function("/{{/}; var x = 1; /}/; function(){")()
entering gcCollect
leaving gcCollect
entering gcCollect
leaving gcCollect
entering gcCollect
leaving gcCollect
entering gcCollect
leaving gcCollect
entering gcCollect
leaving gcCollect
^C

Anyway, fixing this is not quite trivial with the counting-brackets approach because / might be either a division operator or the start of a regexp inside an expression, depending on whether there's another slash on the same expression/line. I should have a patch for this by the weekend.

@maximecb
Copy link
Contributor

Thank you for taking the time to review your code and finding this :)

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

No branches or pull requests

2 participants