I want to let visitors of my web pages to access a textarea where they can write a tiny bit of javascript to configure certain features.
Imagine the javascript to be something like this:
{
max:100;
allowFeedback:false;
filterEnabled:true ;
}
I would want to eval what they write and then my javascript would do something depending on your choices:
so this would be:
var userCode = document.getElementById("textarea").value;
var result = eval(userCode);
..
if (result.filterEnabled) { ... }
if (result.allowFeedback) { ... }
...
The question is: the user could really type any javascript in there ? something malicious, something wrong what can I do to validate its code before executing ?
Many thanks