-
Notifications
You must be signed in to change notification settings - Fork 3
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
🎨 Use filter_var to check IPv4 and IPv6 addresses #10
base: master
Are you sure you want to change the base?
Conversation
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.
Good idea to change this to better to maintain methods, just some minor remarks.
Co-authored-by: Thomas Casteleyn <thomas.casteleyn@me.com>
Co-authored-by: Thomas Casteleyn <thomas.casteleyn@me.com>
Co-authored-by: Thomas Casteleyn <thomas.casteleyn@me.com>
I've updated the code to the suggestions of @Hipska |
'short_name' => $sShortName, | ||
'status' => $this->oCollectionPlan->GetTeemIpOption('default_ip_status'), | ||
); | ||
if (filter_var($sIP, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
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.
You could also rewrite the following:
$sIP = $oVM['managementip'] ?? '';
if (filter_var($sIP, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
To something like:
$sIP = filter_var($oVM['managementip'] ?? '', FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)
if ($sIP !== false) {
Or just if ($sIP) {
, but I think Combodo would prefer the one above.
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.
Yes, we discussed that. But to me it "hurts" to see a bool written into a variable pretending to be a string. (I know now that this is valid PHP, but it just feels not right for me to do this)
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.
Please reopen conversation to let Combodo decide on it.
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.
sorry
Yes, I've overseen this. Co-authored-by: Thomas Casteleyn <thomas.casteleyn@me.com>
Co-authored-by: Thomas Casteleyn <thomas.casteleyn@me.com>
Base information
Symptom (bug) / Objective (enhancement)
filter_var($variable, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)
andfilter_var($variable, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)
when checking for IP addresses.Proposed solution (bug and enhancement)
Make validation of IP addresses more robust due to the use of PHP functions
Checklist before requesting a review
Checklist of things to do before PR is ready to merge
none