Issues

ZF-2420: Zend_Validate_Ip doesn't recognize 0.0.0.0 as a valid ip..

Issue Type: Patch Created: 2008-01-11T10:39:03.000+0000 Last Updated: 2008-02-26T12:56:04.000+0000 Status: Resolved Fix version(s): - 1.0.4 (26/Feb/08)

Reporter: Jordan Raub (ludicruz) Assignee: Michal Minicki (martel) Tags: - Zend_Validate

Related issues: Attachments:

Description

line 62 of Zend_Validate_Ip (release-1.0.3) is "if (!ip2long($valueString)) {" shouldn't this be "if (false === ip2long($valueString)) {" since php versions >= 5.0.3 return boolean false if a string given is not an ip.

I found this from a problem with 0.0.0.0 returning 0 from ip2long and breaking my Zend_Filter_Input validation chain

Comments

Posted by Michal Minicki (martel) on 2008-01-15T03:56:29.000+0000

IP of 0.0.0.0 is in fact a valid IP address (although reserved). Fixed. Thanks, Jordan.

As a side note: I have refactored an accompanying test for more readability.

Hostname tests should also be refactored in the future because it's really hard to tell which test have failed when you iterate the array:

<pre class="highlight">
PHPUnit 3.0.6 by Sebastian Bergmann.

.........................................
.F.......................................
..

Time: 00:00

There was 1 failure:

1) testBasic(Zend_Validate_HostnameTest)
Failed asserting that  is equal to .
/home/martel/Projects/zend-framework/tests/Zend/Validate/HostnameTest.php:81
/home/martel/Projects/zend-framework/tests/Zend/Validate/AllTests.php:177
/home/martel/Projects/zend-framework/tests/Zend/Validate/AllTests.php:214

FAILURES!
Tests: 84, Failures: 1.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts