-
Notifications
You must be signed in to change notification settings - Fork 209
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
Add input validation for toLong #95
base: main
Are you sure you want to change the base?
Conversation
it is possible to have ip value of null, for example from express.
you forgot to add link to your mentioned pull request |
what's the current behavior? as maybe more accurate is to raise an error instead? |
what is the scenario where express returns |
@glensc - you have probably right here, this function should throw an error if the input is invalid, check code there is already at least one other function who does it also. So updated my changes, so now it throws error if not valid ipv4 |
and there can be one more issue - ipv4 aadresses embeded into ipv6 ... in our case few examples for those
|
hint: disable ipv6 listen in your express application (listen to ipv4_all: 0.0.0.0) |
ip.toLong(null); | ||
}, Error); | ||
assert.throws(function () { | ||
ip.toLong(undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false
, empty string ''
, Function
? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would end up testing here this .isV4Format
more as in the end this will be used to validated input - so just added few possible values that can perhaps happens as bad input other than ipv6
This pull request is adding input validation for
toLong
method as for example it is possible to only get long values from ipv4 addresses.