GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — Identifiers inside functions nested in class field initializers are neither renamed nor preserved (`stringArray` produces `X is not a function`) · Issue #1462 · javascript-obfuscator/javascript-obfuscator Closed Labels DescriptionExpected BehaviorIdentifiers declared in a function nested inside a class field initializer, such as the parameter Current BehaviorThose identifiers are neither renamed nor preserved, so a generated name can take the same name. In the example below, the string array calls wrapper is also named class Foo { static [i(0xc0)] = register ({ 'onChange': (b) => { var j = b; return b[j(0xb6)]+b[j(0xb5)]; } }); } // ... function b(c,d){c=c-0xb4;var e=a();var f=e[c];return f;} The same function written inside a class method instead of a class field initializer has its parameter renamed correctly. This is easy to hit with minified input: minifiers commonly name the first parameter Steps to Reproduce
JavaScript Obfuscator Edition
Your Environment
Stack traceMinimal working example that will help to reproduce issueconst JavaScriptObfuscator = require('javascript-obfuscator'); const code = ` function register (options) { return options; } class Foo { static staticField = register({ onChange: (b) => { return b['value'] + b['suffix']; } }); } Foo.staticField.onChange({ value: 'foo', suffix: 'bar' }); `; const obfuscatedCode = JavaScriptObfuscator.obfuscate(code, { identifierNamesGenerator: 'mangled', stringArray: true, stringArrayThreshold: 1, stringArrayWrappersCount: 1, stringArrayWrappersChainedCalls: false }).getObfuscatedCode(); console.log(obfuscatedCode); console.log(eval(obfuscatedCode)); Cause
javascript-obfuscator/src/node/ScopeIdentifiersTraverser.ts Lines 90 to 92 in 67005e2
eslint-scope 8 creates a I have a fix with tests ready and will open a PR referencing this issue. Workaround
Activity
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |