beautifier/js-beautify

Improperly detected unpack deletes part of input

Open

#1,350 创建于 2018年2月22日

在 GitHub 查看
 (2 评论) (1 反应) (0 负责人)JavaScript (8,342 star) (1,460 fork)batch import
good first issueimplementation: javascriptimplementation: pythontype: bug

描述

Using http://jsbeautifier.org/, you can replicate the issue seen below. I noted a few things:

  • Changing the variable name (e.g., test=["testing"];), the issue is gone
  • Removing the semi-colon, the issue is gone
  • Keeping the variable name, but assigning an int, the issue is gone

This also happens with the version downloaded from pip this morning on my local machine (Ubuntu 16.04 LTS)

Input

The code looked like this before beautification:

var _0x3e5f=['testing'];
// This is just a sample script. Paste your real code (javascript or HTML) here.

if ('this_is'==/an_example/){of_beautifier();}else{var a=b?(c%d):e[f];}

Expected Output

The code should have looked like this after beautification:

var _0x3e5f = ['testing'];     
// This is just a sample script. Paste your real code (javascript or HTML) here.
if ('this_is' == /an_example/) {
    of_beautifier();
} else {
    var a = b ? (c % d) : e[f];
}

Actual Output

The code actually looked like this after beautification:

// This is just a sample script. Paste your real code (javascript or HTML) here.
if ('this_is' == /an_example/) {
    of_beautifier();
} else {
    var a = b ? (c % d) : e[f];
}

Steps to Reproduce

Use jsbeautifier.org, paste the code above and see for yourself

Environment

OS: n/a

贡献者指南