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

Issues with obfuscated regex matches

Open paambaati opened this issue 10 years ago • 2 comments

In my code, I do a regex match for a string like this.

str.match('^\\d+$')

This gets obfuscated to -

str.match("\x5e\d\x2b\x24")

This doesn't seem to work though, as seen below -

> str="12345678901234567890";
'12345678901234567890'
> str.match('^\\d+$')
[ '12345678901234567890',
  index: 0,
  input: '12345678901234567890' ]
> str.match("\x5e\d\x2b\x24")
null

paambaati avatar Apr 07 '15 12:04 paambaati

hmm looks like we're loosing characters as '\x5e\d\x2b\x24' == '^d+$'. this is definitely a bug.

as a quick fix (on your end), just pass a RegExp to String#match rather than a string.

stephenmathieson avatar Apr 07 '15 14:04 stephenmathieson

@stephenmathieson Ah, that fixes my issue for now.

paambaati avatar Apr 07 '15 16:04 paambaati