javascript-obfuscator icon indicating copy to clipboard operation
javascript-obfuscator copied to clipboard

Invalid Regular Expression (Range out of order in character class) when obfuscating bundled lodash code

Open thorsent opened this issue 3 years ago • 0 comments

Obfuscated code won't run due to "Invalid Regular Expression" error. Same error in Chrome and Firefox. This happens with the default configuration. I've also systematically set each configuration option to false but the problem persists. There does not seem to be a workaround.

This is occurring in a webpacked bundle and the code appears to be a RegExp that is set in lodash.

Expected Behavior

Obfuscated code should run in browser without error.

Current Behavior

A regular expression is producing invalid JavaScript code.

Uncaught SyntaxError: Invalid regular expression: /\x5cud83c[\x5cudffb-\x5cudfff](?=\x5cud83c[\x5cudffb-\x5cudfff])|(?:[^\x5cud800-\x5cudfff][\x5cu0300-\x5cu036f\x5cufe20-\x5cufe2f\x5cu20d0-\x5cu20ff]?|[\x5cu0300-\x5cu036f\x5cufe20-\x5cufe2f\x5cu20d0-\x5cu20ff]|(?:\x5cud83c[\x5cudde6-\x5cuddff]){2}|[\x5cud800-\x5cudbff][\x5cudc00-\x5cudfff]|[\x5cud800-\x5cudfff])[\x5cufe0e\x5cufe0f]?(?:[\x5cu0300-\x5cu036f\x5cufe20-\x5cufe2f\x5cu20d0-\x5cu20ff]|\x5cud83c[\x5cudffb-\x5cudfff])?(?:\x5cu200d(?:[^\x5cud800-\x5cudfff]|(?:\x5cud83c[\x5cudde6-\x5cuddff]){2}|[\x5cud800-\x5cudbff][\x5cudc00-\x5cudfff])[\x5cufe0e\x5cufe0f]?(?:[\x5cu0300-\x5cu036f\x5cufe20-\x5cufe2f\x5cu20d0-\x5cu20ff]|\x5cud83c[\x5cudffb-\x5cudfff])?)*/: Range out of order in character class

Screenshot of Chrome paused on exception: image

Steps to Reproduce

This original code seems to be the culprit from lodash: var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');

In my case, this is part of a very large webpack bundle (though I have a few separate bundles that exhibit the same problem so I think it may just be lodash).

Your Environment

MacOS Monterey

  • Obfuscator version used: 4.0.0
  • Node version used: 16.14.0

Stack trace

Nothing useful.

Minimal working example that will help to reproduce issue

If necessary for debugging I can send the unobfuscated .js file by email.

thorsent avatar Jul 14 '22 04:07 thorsent