MichaelXF / js-confuser

JS-Confuser is a JavaScript obfuscation tool to make your programs *impossible* to read.
https://js-confuser.com
MIT License
168 stars 28 forks source link

Flatten breaks function with invalid identifier name #89

Closed MichaelXF closed 1 year ago

MichaelXF commented 1 year ago

Config and Small code sample

Config:

{
  target: "node",
  flatten: true
}

Code:

// Input
var object = {
  "my-function": function () {
    console.log("Success");
  },
};

object["my-function"](); // "Success"

// Output
var __p_6528915312_flat_my-function = function ([], [], __p_3339738254) {
    console['log']('Success');
    return __p_3339738254.fkgens5 = {};
};
var object = {
    'my-function': function () {
        var __p_3339738254 = {};
        __p_6528915312_flat_my-function([], [], __p_3339738254);
        if (__p_3339738254['fkgens5']) {
            return __p_3339738254['fkgens5']['YQwDJR'];
        }
    }
};
object['my-function']();

Expected behavior

The program should output "Success"

Actual behavior

SyntaxError: Unexpected token '-'