PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_CheckIP » Bug #6914

Validates wrongly formatted IP

Details

Submitted2006-02-24 03:20 UTC
Frommanantha at gmail dot com
Assignedmj
StatusClosed
PackageNet_CheckIP
PHP Version4.4.0
OSLinux
Roadmaps(Not assigned)

Comments

[2006-02-24 03:20 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.

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+$/

Test script:
---------------
<?php
require_once "Net/CheckIP.php";

if (Net_CheckIP::check_ip("226e+0.33.22.1")) {
echo "ok";
} else {
echo "no";
}
?>