Home » Networking » Net_CheckIP » Bug #6915
Validates wrongly formatted IP
Details
| Submitted | 2006-02-24 03:22 UTC |
|---|---|
| From | manantha at gmail dot com |
| Status | Duplicate |
| Package | Net_CheckIP |
| PHP Version | 4.4.0 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-02-24 03:22 UTC] manantha at gmail dot com
Description:
------------
if (Net_CheckIP::check_ip("226e+0.33.22.1")) {
echo "ok";
}
this returns "ok". but writing this addr into a postgresql database inet field returns an error.
Test script:
---------------
<?php
require_once "Net/CheckIP.php";
if (Net_CheckIP::check_ip("226e+0.33.22.1")) {
echo "ok";
} else {
echo "no";
}
?>
Instead of doing a is_numeric check on each octet, it will be better to do a is_int or a regex /^[0-9]+$/
or check the ip with this regx /^(\d+\.){3}\d+$/