Fix error when ClassExpression is the CallExpression callee

This commit is contained in:
sanex3339
2025-11-30 02:44:31 +04:00
parent cd63f59099
commit c8b25680fd
5 changed files with 29 additions and 5 deletions
+1
View File
@@ -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
+1 -1
View File
@@ -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",
@@ -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/;
@@ -0,0 +1 @@
try { ! class { } ( ) ; } catch { }
+4 -4
View File
@@ -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"