Fix parsing invalid input
authorMihai Bazon <mihai.bazon@gmail.com>
Mon, 9 Nov 2015 11:15:20 +0000 (13:15 +0200)
committerMihai Bazon <mihai.bazon@gmail.com>
Mon, 9 Nov 2015 11:15:20 +0000 (13:15 +0200)
i.e. `x = 1.xe` — because parseFloat("1.xe") returns 1, this parsed as
`x = 1`.

Ref #857

lib/parse.js

index 4c548a2..cb35118 100644 (file)
@@ -182,7 +182,8 @@ function parse_js_number(num) {
     } else if (RE_OCT_NUMBER.test(num)) {
         return parseInt(num.substr(1), 8);
     } else {
-        return parseFloat(num);
+        var val = parseFloat(num);
+        if (val == num) return val;
     }
 };