3 ms·
How is building an intermediate portion of a nested logical statement, using eval() dangerous? Here is the regex for what I allow (only '[' & ']'): value.re
by euroclydon 17y ago
How is building an intermediate portion of a nested logical statement, using eval() dangerous?
Here is the regex for what I allow (only '[' & ']'):
value.replace(/[^(]/g, '').replace(/\(/g, '[')
value.replace(/[^)]/g, '').replace(/\)/g, '],')
I guess the point you all are trying to make is that some javascript text could have been maliciously inserted into the page somehow, and accidentally get eval'd simply because eval is in use, but the page below says that one of the only times eval should be used is to build up complex mathematical expressions. Is there a safe way to build up such expressions? Send it to the server, and invoke a JS engine there? The reason I made my original comment was because I found the eval function to be so helpful in this scenario, b/c I didn't need to use any type of syntax parsing.
http://blogs.msdn.com/ericlippert/archive/2003/11/01/53329.aspx http://blogs.msdn.com/ericlippert/archive/2003/11/01/53329.a...
- tptacek 17y agoIf you are confident about charsets and you whitelist down to known-good characters ([A-Za-z0-9_ \t]) I have nothing snarky to say about the design. Otherwise, try reading this very short thread: http://www.webappsec.org/lists/websecurity/archive/2010-03/msg00044.html http://www.webappsec.org/lists/websecurity/archive/2010-03/m... (It's not exactly your problem but you'll get the flavor.)