mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
String array improvement: fixed bugs
This commit is contained in:
+5
-5
@@ -10,7 +10,7 @@ import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade
|
||||
|
||||
describe('StringArrayRotateFunctionCodeHelper', () => {
|
||||
describe('Base behaviour', () => {
|
||||
const regExp: RegExp = /while *\(-- *_0x([a-f0-9]){4,6}\) *\{/;
|
||||
const regExp: RegExp = /while *\(!!\[]\) *\{/;
|
||||
|
||||
describe('`stringArray` option is set', () => {
|
||||
let obfuscatedCode: string;
|
||||
@@ -58,8 +58,8 @@ describe('StringArrayRotateFunctionCodeHelper', () => {
|
||||
});
|
||||
|
||||
describe('Preserve string array name', () => {
|
||||
const rotateLogicRegExp: RegExp = /b\['push']\(b\['shift']\(\)\);/;
|
||||
const incrementRegExp: RegExp = /f\(\+\+e\);/;
|
||||
const arrayRotateRegExp: RegExp = /c\['push']\(c\['shift']\(\)\);/;
|
||||
const comparisonRegExp: RegExp = /if *\(e *=== *d\) *{/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
@@ -79,11 +79,11 @@ describe('StringArrayRotateFunctionCodeHelper', () => {
|
||||
});
|
||||
|
||||
it('should preserve string array name', () => {
|
||||
assert.match(obfuscatedCode, rotateLogicRegExp);
|
||||
assert.match(obfuscatedCode, arrayRotateRegExp);
|
||||
});
|
||||
|
||||
it('generate valid identifier names', () => {
|
||||
assert.match(obfuscatedCode, incrementRegExp);
|
||||
assert.match(obfuscatedCode, comparisonRegExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+6
-6
@@ -13,7 +13,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
|
||||
describe('Prevailing kind of variables', () => {
|
||||
describe('`var` kind', () => {
|
||||
let obfuscatedCode: string,
|
||||
stringArrayRotateFunctionRegExp: RegExp = /function\(_0x([a-f0-9]){4,6}, *_0x([a-f0-9]){4,6}\){var _0x([a-f0-9]){4,6} *= *function/;
|
||||
stringArrayRotateFunctionTryCatchRegExp: RegExp = /try *{var *_0x([a-f0-9]){4,6}/;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/prevailing-kind-of-variables-var.js');
|
||||
@@ -31,7 +31,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
|
||||
});
|
||||
|
||||
it('Should return correct kind of variables for string array rotate function', () => {
|
||||
assert.match(obfuscatedCode, stringArrayRotateFunctionRegExp);
|
||||
assert.match(obfuscatedCode, stringArrayRotateFunctionTryCatchRegExp);
|
||||
});
|
||||
|
||||
it('Should does not break on obfuscating', () => {
|
||||
@@ -41,7 +41,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
|
||||
|
||||
describe('`const` kind', () => {
|
||||
let obfuscatedCode: string,
|
||||
stringArrayRotateFunctionRegExp: RegExp = /function\(_0x([a-f0-9]){4,6}, *_0x([a-f0-9]){4,6}\){const _0x([a-f0-9]){4,6} *= *function/;
|
||||
stringArrayRotateFunctionTryCatchRegExp: RegExp = /try *{const *_0x([a-f0-9]){4,6}/;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/prevailing-kind-of-variables-const.js');
|
||||
@@ -59,7 +59,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
|
||||
});
|
||||
|
||||
it('Should return correct kind of variables for string array rotate function', () => {
|
||||
assert.match(obfuscatedCode, stringArrayRotateFunctionRegExp);
|
||||
assert.match(obfuscatedCode, stringArrayRotateFunctionTryCatchRegExp);
|
||||
});
|
||||
|
||||
it('Should does not break on obfuscating', () => {
|
||||
@@ -69,7 +69,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
|
||||
|
||||
describe('`let` kind', () => {
|
||||
let obfuscatedCode: string,
|
||||
stringArrayRotateFunctionRegExp: RegExp = /function\(_0x([a-f0-9]){4,6}, *_0x([a-f0-9]){4,6}\){const _0x([a-f0-9]){4,6} *= *function/;
|
||||
stringArrayRotateFunctionTryCatchRegExp: RegExp = /try *{const *_0x([a-f0-9]){4,6}/;
|
||||
|
||||
beforeEach(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/prevailing-kind-of-variables-let.js');
|
||||
@@ -87,7 +87,7 @@ describe('StringArrayRotateFunctionTemplate', () => {
|
||||
});
|
||||
|
||||
it('Should return correct kind of variables for string array rotate function', () => {
|
||||
assert.match(obfuscatedCode, stringArrayRotateFunctionRegExp);
|
||||
assert.match(obfuscatedCode, stringArrayRotateFunctionTryCatchRegExp);
|
||||
});
|
||||
|
||||
it('Should does not break on obfuscating', () => {
|
||||
|
||||
Reference in New Issue
Block a user