From 18d37ac761d8f9bb3904d447ddbb0ac471fc161c Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Mon, 9 Nov 2015 13:15:20 +0200 Subject: Fix parsing invalid input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i.e. `x = 1.xe` — because parseFloat("1.xe") returns 1, this parsed as `x = 1`. Ref #857 --- lib/parse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/parse.js b/lib/parse.js index 4c548a26..cb35118a 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -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; } }; -- cgit v1.2.3