tddbin / tddbin-frontend

The source of TDDbin. -
http://tddbin.com
MIT License
225 stars 36 forks source link

Fix recursive function definition exploit #23

Open orcist opened 8 years ago

orcist commented 8 years ago

If a function is defined like let foo = () => foo() and then called foo(), the site lags in an infinite loop, some maximum stack reached error should be displayed perhaps instead?

wolframkriesing commented 8 years ago

yep, this would be nice to have handled, any suggestion on how to catch it?

orcist commented 8 years ago

A simple try-catch wrapper around the entire executed code should suffice, something like try { foo(); bar(); baz(); } catch (e) { doSomethingWithException(e); }

wolframkriesing commented 8 years ago

would have been nice, i didn't get that to catch it, I tried it in tddbin (just on the site) if you have a better idea fire away, i am curious

orcist commented 8 years ago

Maybe replace Function.prototype.call() method with a try-catch wrapped version before executing function definition?