Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insufficient escape in first name #18

Open
nhahtdh opened this issue Oct 29, 2015 · 3 comments
Open

Insufficient escape in first name #18

nhahtdh opened this issue Oct 29, 2015 · 3 comments

Comments

@nhahtdh
Copy link

nhahtdh commented Oct 29, 2015

From https://github.com/callumacrae/tryregex/blob/master/app/assets/js/globalFuncs.js#L72

data.firstEscaped = firstName.replace(/([$()*+.?\[^|\]])/g, '\\$1');

It is missing escape for {, }, \ and / (the last one for RegExp literal only). The code could be changed to:

data.firstEscaped = firstName.replace(/([$()*+.?\[^|\]{}\/\\])/g, '\\$1');

Or without using capturing group:

data.firstEscaped = firstName.replace(/[$()*+.?\[^|\]{}\/\\]/g, '\\$&');
@callumacrae
Copy link
Owner

Sure. Does this fix any bugs? Are there any cases where the name is escaped improperly?

@nhahtdh
Copy link
Author

nhahtdh commented Oct 29, 2015

Sure, it's very unlikely anyone has this name, but since you escaped all other characters, why not go for a full coverage?

setName("lol!@#$%^&*()_+-={}[]|\\:\";'<>?,./")

@callumacrae
Copy link
Owner

fair enough! would you be able to send a PR? Otherwise, I'll do it later.

Thanks!

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

No branches or pull requests

2 participants