beautifier/js-beautify

Improperly detected unpack deletes part of input

Open

#1,350 opened on 2018年2月22日

GitHub で見る
 (2 comments) (1 reaction) (0 assignees)JavaScript (8,342 stars) (1,460 forks)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

コントリビューターガイド