PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Networking » Net_IPv6 » Bug #3404

checkIPv6() is case sensitive

Details

Submitted2005-02-08 15:31 UTC
Fromelfrink at introweb dot nl
Assigneddufuz
StatusClosed
PackageNet_IPv6
PHP Version4.3.10
OSFreeBSD
Roadmaps(Not assigned)

Comments

[2005-02-08 15: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

[2005-02-08 15: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 08: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!