I want visitors to my web pages to access a text area where they can write a small bit of javascript to configure certain functions.
Imagine javascript looks something like this:
{
max: 100;
allowFeedback false;
filterEnabled: true,
}
I would like to evaluate what they write, and then my javascript will do something depending on your options:
so this will be:
var userCode = document.getElementById ("textarea"). value;
var result = eval (userCode);
.. if (result.filterEnabled) {...}
if (result.allowFeedback) {...} ...
Question: can user really enter any javascript there? something evil, something wrong, what can I do to check its code before execution?
Many thanks
source share