js-confuser
js-confuser copied to clipboard
ForInStatement of a variable in window
Describe the bug:
The program enters an infinite loop and does not produce the expected output.
Config and Small code sample
Version 2.0.0
Config:
{
target: "node",
preset: "medium"
}
Code:
window.list = {
test1: 0,
};
function test() {
for (scene in window.list) {
console.log('test');
};
}
test();
Expected behavior
Should obfuscate my code.
Actual behavior
Error message:
TypeError: Property left of ForInStatement expected node to be of a type ["VariableDeclaration","LVal"] but instead got "CallExpression" at Object.s [as validate]
Additional context
2.0.0 Low Preset does not do the error 1.7.3 does not do the error at all
Looks to be the "Global Concealing" option
Thanks, great find. The problem was Global Concealing on non-defined identifiers in For-In/For-Of statements. Fixed for next release.
I would recommend defining every variable you use, the obfuscator handles them better. Ex:
window.list = {
test1: 0,
};
function test2() {
var scene; // <- Define variable to avoid this
for (scene in window.list) {
console.log("test");
}
}
test2();
// "test"
Fixed on development version of JS-Confuser.com: Demo link.