ZF-5186: Zend_Validate_Ip::isValid() doesn't return false for invalid IP addresses after r13098

Description

The addition of IPv6 support to Zend_Validate_IP in r13098 is causing invalid IP addresses to return a warning when calling Zend_Gdata_Validate_Ip::isValid() rather than false as expected.

Test output:

$ phpunit Zend_Validate_IpTest
PHPUnit 3.3.1 by Sebastian Bergmann.

E..EE.

Time: 0 seconds

There were 3 errors:

1) testBasic(Zend_Validate_IpTest)
inet_pton(): Unrecognized address 0.0.0.256
.../library/Zend/Validate/Ip.php:62
.../library/Zend/Validate/Ip.php:62

2) testInvalidIpForZF4809(Zend_Validate_IpTest)
inet_pton(): Unrecognized address 1.2.333
.../library/Zend/Validate/Ip.php:62
.../library/Zend/Validate/Ip.php:62

3) testInvalidIpForZF3435(Zend_Validate_IpTest)
inet_pton(): Unrecognized address 192.168.0.2 adfs
.../library/Zend/Validate/Ip.php:62
.../library/Zend/Validate/Ip.php:62

FAILURES!
Tests: 6, Assertions: 6, Errors: 3.

Comments

Resolved for trunk in r13104.

Marking as fixed for next minor release.

Merged from trunk into release-1.7 branch as r13289.

Marking as fixed for next mini release.

Using /svn/framework/standard/branches/release-1.7/ @ r13981, I am getting warnings with inet_pton.

I don't know how closely related it is to this issue, but it seems like hostname validation first verifies if the hostname is an IP, and while it returns false, a warning still goes off. There is some error suppressing in Zend_Validate_Ip...

inet_pton() [function.inet-pton]: Unrecognized address [...]

        [1] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/Validate/Ip.php
                [line] => 62
                [function] => inet_pton

        [2] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/Validate/Hostname.php
                [line] => 284
                [function] => isValid
                [class] => Zend_Validate_Ip

        [3] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/Uri/Http.php
                [line] => 448
                [function] => isValid
                [class] => Zend_Validate_Hostname

        [4] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/Uri/Http.php
                [line] => 280
                [function] => validateHost
                [class] => Zend_Uri_Http

        [5] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/Uri/Http.php
                [line] => 154
                [function] => valid
                [class] => Zend_Uri_Http

        [6] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/Uri.php
                [line] => 132
                [function] => __construct
                [class] => Zend_Uri_Http

        [7] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/Http/Client.php
                [line] => 257
                [function] => factory
                [class] => Zend_Uri

        [8] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/Http/Client.php
                [line] => 243
                [function] => setUri
                [class] => Zend_Http_Client

        [9] => Array
            (
                [file] => /mnt/local/home/lphtaskestimation/lib/Zend/OpenId/Consumer.php
                [line] => 490
                [function] => __construct
                [class] => Zend_Http_Client

Louis, Can you open a new issue, and mention this issue's ID in the description? I'd rather not re-open this bug, since I'm not positive that this is the same issue, and we already pushed out a fix for this issue in a past release.

Hey Louis I am having the same issue, I get a PHP WARNING when ever I use the Email Validate function and the error is from inet_pton

Error Number: 2

Error Type: PHP WARNING

Error String: inet_pton() [function.inet-pton]: Unrecognized address domain.com.au

Error File: /usr/local/www/data/project.com.au/library/Zend/Validate/Ip.php

Error Line: 62

0 errorHandler(2, inet_pton() [function.inet-pton]: Unrecognized address kintek.com.au, /usr/local/www/data/project.com.au/library/Zend/Validate/Ip.php, 62, Array ([value] => domain.com.au,[valueString] => domain.com.au))

Obviously it shouldnt be checking if a domain is an IP right? and if so why cause this error? This is 1.7.5 im using.

Is there an official bug report for this somewhere?