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

Better validation of ip address for set_urg_ip #64

Open
wants to merge 1 commit into
base: indigo-devel
Choose a base branch
from
Open

Better validation of ip address for set_urg_ip #64

wants to merge 1 commit into from

Conversation

worldpotato
Copy link

Use the ipaddress library to validate the given ip-addresses.

Don't use a loop to fill up missing zeros.

Before the given ip was checked for their format
which means that the format is like AAA.BBB.CCC.DDD.
But it was never checked if it is actually a valid ip and not only
in the correct format.

Parsing it with ipaddress will ensure that the given ip is valid.

Using zfill to fill missing zeros just feels nicer.

Also remove some trailing whitespaces.

Use the ipaddress library to validate the given ip-addresses.

Don't use a loop to fill up missing zeros.

Before the given ip was checked for their format
which means that the format is like AAA.BBB.CCC.DDD.
But it was never checked if it is actually a valid ip and not only
in the correct format.

Parsing it with ipaddress will ensure that the given ip is valid.

Using zfill to fill missing zeros just feels nicer.
x = "0" + x
parsed += x
return parsed
ip = str(ipaddress.ip_address(argument))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argument need to be cast to unicode, unicode(argument)

@tonybaltovski
Copy link
Member

Thanks! Looks good but minor the one little change.

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

Successfully merging this pull request may close these issues.

2 participants