diff --git a/CHANGELOG.md b/CHANGELOG.md index e65d3f70..39c156f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ v4.1.2 * Fix `controlFlowFlattening` + optional chaining compatibility. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1325 * Don't obfuscate import.meta.*. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1267 * Revert `Improved stringArray calls wrapper templates` commit. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1330 +* Fix error when ClassExpression is the CallExpression callee. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1132 * Don't publish root index.ts files to NPM. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1252 * Update `class-validator` version. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1324 * Update other dependencies diff --git a/package.json b/package.json index 666183d5..5af23684 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "types": "typings/index.d.ts", "dependencies": { - "@javascript-obfuscator/escodegen": "2.3.0", + "@javascript-obfuscator/escodegen": "2.3.1", "@javascript-obfuscator/estraverse": "5.4.0", "acorn": "8.15.0", "assert": "2.1.0", diff --git a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts index 483a9489..07761c9f 100644 --- a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts +++ b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts @@ -1049,6 +1049,28 @@ describe('JavaScriptObfuscator', () => { }); }); + // https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1132 + describe('CallExpression ClassExpression crash fix', () => { + const regExp: RegExp = /try *\{!class *\{} *\(\);} *catch *\{}/; + + let obfuscatedCode: string; + + beforeEach(() => { + const code: string = readFileAsString(__dirname + '/fixtures/call-expression-class-expression.js'); + + obfuscatedCode = JavaScriptObfuscator.obfuscate( + code, + { + ...NO_ADDITIONAL_NODES_PRESET + } + ).getObfuscatedCode(); + }); + + it('should not throw', () => { + assert.match(obfuscatedCode, regExp); + }); + }); + describe('mangled identifier names generator', () => { const regExp: RegExp = /var c *= *0x1/; diff --git a/test/functional-tests/javascript-obfuscator/fixtures/call-expression-class-expression.js b/test/functional-tests/javascript-obfuscator/fixtures/call-expression-class-expression.js new file mode 100644 index 00000000..c7cfc847 --- /dev/null +++ b/test/functional-tests/javascript-obfuscator/fixtures/call-expression-class-expression.js @@ -0,0 +1 @@ +try { ! class { } ( ) ; } catch { } diff --git a/yarn.lock b/yarn.lock index d2fddd2f..6c1be1ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -329,10 +329,10 @@ resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== -"@javascript-obfuscator/escodegen@2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@javascript-obfuscator/escodegen/-/escodegen-2.3.0.tgz#ff7eb7f8a7c004532e93b14ae8b2196dcf9a1a9e" - integrity sha512-QVXwMIKqYMl3KwtTirYIA6gOCiJ0ZDtptXqAv/8KWLG9uQU2fZqTVy7a/A5RvcoZhbDoFfveTxuGxJ5ibzQtkw== +"@javascript-obfuscator/escodegen@2.3.1": + version "2.3.1" + resolved "https://registry.yarnpkg.com/@javascript-obfuscator/escodegen/-/escodegen-2.3.1.tgz#a534e73740830d6c7546ca686773b40b09a6b9d1" + integrity sha512-Z0HEAVwwafOume+6LFXirAVZeuEMKWuPzpFbQhCEU9++BMz0IwEa9bmedJ+rMn/IlXRBID9j3gQ0XYAa6jM10g== dependencies: "@javascript-obfuscator/estraverse" "^5.3.0" esprima "^4.0.1"