-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
isUrl check causes infinite loop #109
Comments
Also, I think this part is wrong |
@shankar0306 it's a regular expression denial of service. Not sure what the best course of action is here beyond replacing the check with a parser that doesn't use regex. @Radagaisus the |
I think limit of 2000 chars is reasonable: http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url |
It would probably be more efficient to put the length > 2083 check before the regex. This way, the regex is never used for really long strings. I'm pretty sure that checking the length of the string is a faster operation than that really long & hairy regex. |
@corvi42 RegExp in V8 is fast enough that checks on urls of any length should be considered negligible. The DOS problem arrises from excessive backtracking. |
@chriso I understand that the infinite loop issue is not from the performance of the regex, and I also appreciate that V8 is a mighty powerful machine. It was just a passing observation. In general I think its good style to fail fast, and avoid more costly operations when the code is functionally equivalent. Its really a very minor point, and I'm sure won't really affect anybody's code adversely either way. Do as you wish. |
I think that problem in the regexp used in the node-validator. If you delete "&" at the end of the url it will work fine. Have you seen this https://gist.github.com/729294 ? EDIT: I have also added regex that used in node-validator at the moment of 0e391de |
Following code can be use to reproduce the infinite loop
MDB js stack
The text was updated successfully, but these errors were encountered: