From d3655cd07f40f3f6603e44089dfd8734870663c1 Mon Sep 17 00:00:00 2001 From: Trey Griffith Date: Wed, 8 May 2013 15:29:46 -0400 Subject: [PATCH] add a test for zero-length string in is_identifier_string, which is used in property compression. Also added a test exercising the change. --- lib/parse.js | 2 +- test/compress/properties.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/parse.js b/lib/parse.js index b3687201..418f81ee 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -172,7 +172,7 @@ function is_identifier_string(str){ if (!is_identifier_char(str.charAt(i))) return false; } - return true; + return str.length > 0; }; function parse_js_number(num) { diff --git a/test/compress/properties.js b/test/compress/properties.js index d52680c2..f490fd86 100644 --- a/test/compress/properties.js +++ b/test/compress/properties.js @@ -19,12 +19,14 @@ dot_properties: { a["if"] = "if"; a["*"] = "asterisk"; a["\u0EB3"] = "unicode"; + a[""] = "whitespace"; } expect: { a.foo = "bar"; a["if"] = "if"; a["*"] = "asterisk"; a.\u0EB3 = "unicode"; + a[""] = "whitespace"; } } @@ -38,11 +40,13 @@ dot_properties_es5: { a["if"] = "if"; a["*"] = "asterisk"; a["\u0EB3"] = "unicode"; + a[""] = "whitespace"; } expect: { a.foo = "bar"; a.if = "if"; a["*"] = "asterisk"; a.\u0EB3 = "unicode"; + a[""] = "whitespace"; } }