beautifier / js-beautify

Beautifier for javascript
https://beautifier.io
MIT License
8.63k stars 1.39k forks source link

[Feature Request] More Unescape Support #1343

Open QuasarX opened 6 years ago

QuasarX commented 6 years ago

Description

Can you add new feature for unescape non-ascii chars Like this; 0xc8, \u3010, \x72, ![]

Input

The code looked like this before beautification:

var x = {
    'leaderboardNick': {
        'Player': '\x72\x67\x62\x61\x28\x32\x32\x32\x2c\x20\x32\x33\x2c\x20\x38\x38\x2c\x20\x31\x29',
        '\u3010\u20B1\u20AC\u3011':  # FFF,
    },
    'emoticons': {},
    'indicator': ![],
    'indicatorMaxSize': 0xc8
};

Expected Output

The code should have looked like this after beautification:

var x = {
    'leaderboardNick': {
        'Player': 'rgba(222, 23, 88, 1)',
        '【₱€】': #FFF,
    },
    'emoticons': {},
    'indicator': false,
    'indicatorMaxSize': 200
};

Actual Output

The code actually looked like this after beautification:

var x = {
    'leaderboardNick': {
        'Player': 'rgba(222, 23, 88, 1)',
        '【₱€】': #FFF,
    },
    'emoticons': {},
    'indicator': ![],
    'indicatorMaxSize': 0xc8
};

Steps to Reproduce

used http://jsbeautifier.org/

Environment

OS: Windows 10

Settings

image

bitwiseman commented 6 years ago

The unescape parts of this already work (from the output your provided). The other two elements (0xc8 and ![]) aren't unescaping but rather some kind of deobfuscation rules. These may be implemented eventually, but are a low priority.