Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2b2

Bug #3404 checkIPv6() is case sensitive
Submitted: 2005-02-08 10:31 UTC Modified: 2006-12-27 00:03 UTC
From: elfrink at introweb dot nl Assigned: dufuz
Status: Closed Package: Net_IPv6
PHP Version: 4.3.10 OS: FreeBSD
Roadmaps: (Not assigned)    
Subscription  


 [2005-02-08 10:31 UTC] elfrink at introweb dot nl
Description: ------------ checkIPv6() only works with capital letters A-F, due to the use of dechex() function to check for a valid part. Reproduce code: --------------- require("Net/IPv6.php"); echo (Net_IPv6::checkIPv6("2010:0588:0000:faef:1428:0000:0000:57ab") ? "true" : "false"); Expected result: ---------------- true Actual result: -------------- false

Comments

 [2005-02-08 10:35 UTC] elfrink at introweb dot nl
Fix (if there's a previous fix attached to this bug report: ignore it, I copied/pasted the wrong part): --- Net/IPv6.php Tue Feb 8 16:27:36 2005 +++ ../IPv6.php Tue Feb 8 15:25:56 2005 @@ -198,7 +198,8 @@ $ipv6 = explode(':', $ipPart[0]); for ($i = 0; $i < count($ipv6); $i++) { $dec = hexdec($ipv6[$i]); - if ($ipv6[$i] >= 0 && $dec <= 65535 && $ipv6[$i] == strtoupper(dechex($dec))) { + $hex = strtoupper(preg_replace("/^[0]{1,3}(.*[0-9a-fA-F])$/", "\\1", $ipv6[$i])); + if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex == strtoupper(dechex($dec))) { $count++; } }
 [2005-02-10 03:21 UTC] alexmerz at php dot net
I will check the fix and submit it to CVS if it is ok during the weekend. Thank you!
 [2005-02-13 16:50 UTC] dufuz
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Net_IPv6