mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added tests for prohibited single FunctionDeclaration
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+29
@@ -780,6 +780,35 @@ describe('IfStatementSimplifyTransformer', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: `FunctionDeclaration` as prohibited single statement', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
'if *\\(!!\\[]\\) *{ *' +
|
||||
'function _0x([a-f0-9]){4,6} *\\(\\) *{} *' +
|
||||
'} *else *{ *' +
|
||||
'function _0x([a-f0-9]){4,6} *\\(\\) *{} *' +
|
||||
'}'
|
||||
);
|
||||
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/function-declaration-as-prohibited-single-statement.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
minify: true
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not simplify if statement', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
function foo() {
|
||||
if (true) {
|
||||
function foo() {}
|
||||
} else {
|
||||
function bar() {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user