javascript - SyntaxError: missing : after property id - after obfuscation -


obfuscated code raising error "syntaxerror: missing : after property id".

code checked on lint , passing without errors or warnings.

this original code (which first line in js document):

var pgetcolor = { 'ab': '#cad17d', 'bc': '#7dd1ae', 'cl': '#919aff', 'ci': '#ffe291', 'hb': '#84dbd5', 'on': '#aa84db', 'pm': '#db848a', 'sr': '#b5db84', 'ts': '#c96b9b', 'is': '#ffc926', 'free': '#5fcf68' }; 

this error report:

enter image description here

what i'm doing wrong?

it's bug in the obfuscator you're using. code

var pgetcolor = { 'ab': '#cad17d', 'bc': '#7dd1ae', 'cl': '#919aff', 'ci': '#ffe291', 'hb': '#84dbd5', 'on': '#aa84db', 'pm': '#db848a', 'sr': '#b5db84', 'ts': '#c96b9b', 'is': '#ffc926', 'free': '#5fcf68' }; 

is getting turned (i added line break):

var _0x5523=["\x41\x42","\x23\x43\x41\x44\x31\x37\x44","\x42\x43","\x23\x37\x44\x44\x31\x41\x45","\x43\x4c","\x23\x39\x31\x39\x41\x46\x46","\x43\x49","\x23\x46\x46\x45\x32\x39\x31","\x48\x42","\x23\x38\x34\x44\x42\x44\x35","\x4f\x4e","\x23\x41\x41\x38\x34\x44\x42","\x50\x4d","\x23\x44\x42\x38\x34\x38\x41","\x53\x52","\x23\x42\x35\x44\x42\x38\x34","\x54\x53","\x23\x43\x39\x36\x42\x39\x42","\x49\x53","\x23\x46\x46\x43\x39\x32\x36","\x46\x52\x45\x45","\x23\x35\x46\x43\x46\x36\x38"]; var pgetcolor={_0x5523[0]:_0x5523[1],_0x5523[2]:_0x5523[3],_0x5523[4]:_0x5523[5],_0x5523[6]:_0x5523[7],_0x5523[8]:_0x5523[9],_0x5523[10]:_0x5523[11],_0x5523[12]:_0x5523[13],_0x5523[14]:_0x5523[15],_0x5523[16]:_0x5523[17],_0x5523[18]:_0x5523[19],_0x5523[20]:_0x5523[21]}; // ------------^^^^^^^^^^ //             wrong (as ones follow) 

it's invalid have _0x5523[0] property name in object initializer. seem have confused using string literals rather property name literals on left-hand side of : — it's being overzealous string substitution. (see below if didn't quite understand meant "string literal" vs. "property name literal".) since you're doing correct , reasonable, it's bug in obfuscator.

i use different obfuscator, or better yet, compiler closure compiler.

if change code use property name literals instead:

var pgetcolor = { ab: '#cad17d', bc: '#7dd1ae', cl: '#919aff', ci: '#ffe291', hb: '#84dbd5', on: '#aa84db', pm: '#db848a', sr: '#b5db84', ts: '#c96b9b', is: '#ffc926', free: '#5fcf68' }; 

...the result fine:

var _0x8d33=["\x23\x43\x41\x44\x31\x37\x44","\x23\x37\x44\x44\x31\x41\x45","\x23\x39\x31\x39\x41\x46\x46","\x23\x46\x46\x45\x32\x39\x31","\x23\x38\x34\x44\x42\x44\x35","\x23\x41\x41\x38\x34\x44\x42","\x23\x44\x42\x38\x34\x38\x41","\x23\x42\x35\x44\x42\x38\x34","\x23\x43\x39\x36\x42\x39\x42","\x23\x46\x46\x43\x39\x32\x36","\x23\x35\x46\x43\x46\x36\x38"]; var pgetcolor={ab:_0x8d33[0],bc:_0x8d33[1],cl:_0x8d33[2],ci:_0x8d33[3],hb:_0x8d33[4],on:_0x8d33[5],pm:_0x8d33[6],sr:_0x8d33[7],ts:_0x8d33[8],is:_0x8d33[9],free:_0x8d33[10]}; 

but there times when want use string literals property names (for instance, if property name has space in it, or reserved word).


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -