Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change Log

v5.4.4
---
* Fixed `Invalid regular expression` error when obfuscating code that uses ES2025 RegExp pattern modifiers (e.g. `/(?i:abc)/`). Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1410

v5.4.3
---
* Fixed `controlFlowFlattening` occasionally dropping the `?.` short-circuit on `foo?.(arg)` calls, causing `TypeError: <X> is not a function`. Fixes https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1408
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "javascript-obfuscator",
"version": "5.4.3",
"version": "5.4.4",
"description": "JavaScript obfuscator",
"keywords": [
"obfuscator",
Expand Down
2 changes: 1 addition & 1 deletion src/constants/EcmaVersion.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as acorn from 'acorn';

export const ecmaVersion = <acorn.Options['ecmaVersion'] & number>13;
export const ecmaVersion = <acorn.Options['ecmaVersion'] & number>2026;
46 changes: 46 additions & 0 deletions test/functional-tests/issues/issue1410.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { assert } from 'chai';
import { NO_ADDITIONAL_NODES_PRESET } from '../../../src/options/presets/NoCustomNodes';
import { JavaScriptObfuscator } from '../../../src/JavaScriptObfuscatorFacade';

//
// https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1410
//
describe('Issue #1410', () => {
describe('ES2025 RegExp pattern modifiers should be parsed without errors', () => {
describe('inline case-insensitive modifier `(?i:...)`', () => {
let obfuscatedCode: string;

before(() => {
const code: string = `console.log(/(?i:abc)/.test('ABC'));`;

obfuscatedCode = JavaScriptObfuscator.obfuscate(code, {
...NO_ADDITIONAL_NODES_PRESET
}).getObfuscatedCode();
});

it('should not throw an `Invalid regular expression` error and should preserve the regex literal', () => {
assert.match(obfuscatedCode, /\/\(\?i:abc\)\//);
});

it('should produce semantically equivalent code', () => {
assert.isTrue(eval(`/(?i:abc)/.test('ABC')`));
});
});

describe('disabled modifier `(?-i:...)` within a case-insensitive regex', () => {
let obfuscatedCode: string;

before(() => {
const code: string = `console.log(/(?-i:abc)/i.test('ABC'));`;

obfuscatedCode = JavaScriptObfuscator.obfuscate(code, {
...NO_ADDITIONAL_NODES_PRESET
}).getObfuscatedCode();
});

it('should not throw an `Invalid regular expression` error and should preserve the regex literal', () => {
assert.match(obfuscatedCode, /\/\(\?-i:abc\)\/i/);
});
});
});
});
Loading