Fixed missing space between keywords (return, throw, typeof) and Unicode surrogate pair identifiers in compact mode

This commit is contained in:
sanex3339
2026-03-22 18:36:46 +07:00
parent 84861e8e39
commit 3865b64f5f
5 changed files with 52 additions and 6 deletions
+4
View File
@@ -1,5 +1,9 @@
Change Log
v5.4.1
---
* Fixed missing space between keywords (`return`, `throw`, `typeof`) and Unicode surrogate pair identifiers in compact mode. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1112
v5.4.0
---
* Add support for `import attributes`. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1256
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "5.4.0",
"version": "5.4.1",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
@@ -21,7 +21,7 @@
},
"types": "typings/index.d.ts",
"dependencies": {
"@javascript-obfuscator/escodegen": "2.4.0",
"@javascript-obfuscator/escodegen": "2.4.1",
"@javascript-obfuscator/estraverse": "5.4.0",
"@vercel/blob": ">=0.23.0",
"acorn": "8.15.0",
@@ -0,0 +1,3 @@
(function(𝐜𝐨𝐧𝐭𝐞𝐱𝐭) {
return 𝐜𝐨𝐧𝐭𝐞𝐱𝐭;
})(42)
@@ -0,0 +1,39 @@
import { assert } from 'chai';
import { NO_ADDITIONAL_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes';
import { readFileAsString } from '../../helpers/readFileAsString';
import { JavaScriptObfuscator } from '../../../src/JavaScriptObfuscatorFacade';
//
// https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1112
//
describe('Issue #1112', () => {
describe('Unicode mathematical bold identifiers should have correct spacing after keywords', () => {
let testFunc: () => void;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/issue1112.js');
testFunc = () => {
const obfuscatedCode: string = JavaScriptObfuscator.obfuscate(code, {
...NO_ADDITIONAL_NODES_PRESET,
reservedNames: ['𝐜𝐨𝐧𝐭𝐞𝐱𝐭'],
compact: true,
seed: 1
}).getObfuscatedCode();
const result = eval(obfuscatedCode);
if (result !== 42) {
throw new Error(
`Expected 42, got ${result}. ` +
`Missing space between keyword and Unicode identifier.`
);
}
};
});
it('should produce valid code with Unicode surrogate pair identifiers', () => {
assert.doesNotThrow(testFunc);
});
});
});
+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.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@javascript-obfuscator/escodegen/-/escodegen-2.4.0.tgz#9d2b19b94793106cafa5cd5041c4e40d42943fb7"
integrity sha512-h9cJ/qb3Y3c1jMQPWypt2CGTFgP34V5OtWLqoOCjV6CT/DUXMZFpoTAfDHpuUrRP0oxNd0UwnVAsPtPuYsoXxQ==
"@javascript-obfuscator/escodegen@2.4.1":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@javascript-obfuscator/escodegen/-/escodegen-2.4.1.tgz#6062541cb3027912e9304dd15f8a5ee5946de247"
integrity sha512-YrEJJDr4cb+pIQKWzHFoDlDkQzatcrNB6OhAD6iTSwiKwzZUMVdobwbOuLpF4EiLxUj0qP28Xl1saTHYzIPCLg==
dependencies:
"@javascript-obfuscator/estraverse" "^5.3.0"
esprima "^4.0.1"