I also came across this. As others have said, eval comes in handy when you create Javascript on the fly, and then want it to run in the browser. My use of this technique is to do small things, such as a simple function that will just make a callback on the server when a button is clicked. Depending on the circumstances, there may be two functions or only one. I also used it to display information that changes from a database. Information is always plain text. Thus, no injection attack can be carried out.
In any case, I also came across this Javascript EVAL restriction, and it seems to me that there is a limit of 1024 characters. When I move on to this, I start getting weird things like eval, just spitting out the source code. This is really obvious, because I am walking around before sending to the browser, so I can have things like single and double quotes in the text, without any problems. (And all the noises help prevent injections.)
I am also a supporter of the man who said to use getcript in jQuery. It works as well as eval without size restrictions. The only additional step you should take is to create a Javascript file first.
I hope this helps and answers the original question about posters. I believe the size limit is 1024 bytes.
source share