Skip to content
This repository has been archived by the owner on May 25, 2020. It is now read-only.

Issues with obfuscated regex matches #24

Open
paambaati opened this issue Apr 7, 2015 · 2 comments
Open

Issues with obfuscated regex matches #24

paambaati opened this issue Apr 7, 2015 · 2 comments
Labels

Comments

@paambaati
Copy link

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
@stephenmathieson
Copy link
Owner

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.

@paambaati
Copy link
Author

@stephenmathieson Ah, that fixes my issue for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants