amount = amount.replace(/[\',]/g, "")
+ // Make sure no code wich is not a math expression ends up in eval().
+ if (!amount.match(/^[0-9 ()\-+*/.]*$/))
+ return 0;
+
/* jshint -W061 */
- return eval(amount);
+ try {
+ return eval(amount);
+ } catch (err) {
+ return 0;
+ }
};
ns.round_amount = function(amount, places) {