cvs: pear /Net_IPv6 IPv6.php package2.xml /Net_IPv6/tests NetIPv6Test.php

From: Date: Mon, 18 May 2009 01:18:20 +0000
Subject: cvs: pear /Net_IPv6 IPv6.php package2.xml /Net_IPv6/tests NetIPv6Test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-56110@lists.php.net to get a copy of this message
alexmerz Mon May 18 01:18:20 2009 UTC Modified files: /pear/Net_IPv6 package2.xml IPv6.php /pear/Net_IPv6/tests NetIPv6Test.php Log: fix #14747, #15947, #16220, prepare for release 1.1.0b2

http://cvs.php.net/viewvc.cgi/pear/Net_IPv6/package2.xml?r1=1.4&r2=1.5&diff_format=u Index: pear/Net_IPv6/package2.xml diff -u pear/Net_IPv6/package2.xml:1.4 pear/Net_IPv6/package2.xml:1.5 --- pear/Net_IPv6/package2.xml:1.4 Tue Oct 28 02:06:00 2008 +++ pear/Net_IPv6/package2.xml Mon May 18 01:18:19 2009 @@ -19,10 +19,10 @@ <email>alexander.merz@web.de</email> <active>yes</active> </lead> - <date>2008-10-28</date> - <time>18:15:09</time> + <date>2008-05-18</date> + <time>03:08:00</time> <version> - <release>1.1.0b1</release> + <release>1.1.0b2</release> <api>1.1.0b1</api> </version> <stability> @@ -31,11 +31,10 @@ </stability> <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD</license> <notes> - Because this release adds a new method and some bug tickets are still open, the package - release is named as Beta, instead of releasing a 5th RC version. - - #14728 add parseAddress(), thanks to Nicholas Williams! - #14767 most CS issues should be solved + Fixed: + #14747 Compressing an already compressed IP returns the IP "as is" now + #15947 checkIPv6 returned true although the IP was too long + #16220 using the wrong variable in _bin2Ip </notes> <contents> <dir name="/"> @@ -54,18 +53,38 @@ </dependencies> <phprelease /> <changelog> - <version> - <release>1.1.0RC4</release> - <api>1.1.0RC4</api> - </version> - <stability> - <release>beta</release> - <api>beta</api> - </stability> - <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD</license> - <notes> - take care of prefix length specification in an address, thanks to Jens Ott - </notes> + <release> + <version> + <release>1.1.0b1</release> + <api>1.1.0b1</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD</license> + <notes> + Because this release adds a new method and some bug tickets are still open, the package + release is named as Beta, instead of releasing a 5th RC version. + + #14728 add parseAddress(), thanks to Nicholas Williams! + #14767 most CS issues should be solved + </notes> + </release> + <release> + <version> + <release>1.1.0RC4</release> + <api>1.1.0RC4</api> + </version> + <stability> + <release>beta</release> + <api>beta</api> + </stability> + <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD</license> + <notes> + take care of prefix length specification in an address, thanks to Jens Ott + </notes> + </release> <release> <version> <release>1.1.0RC3</release> http://cvs.php.net/viewvc.cgi/pear/Net_IPv6/IPv6.php?r1=1.20&r2=1.21&diff_format=u Index: pear/Net_IPv6/IPv6.php diff -u pear/Net_IPv6/IPv6.php:1.20 pear/Net_IPv6/IPv6.php:1.21 --- pear/Net_IPv6/IPv6.php:1.20 Mon Nov 3 18:21:01 2008 +++ pear/Net_IPv6/IPv6.php Mon May 18 01:18:19 2009 @@ -19,7 +19,7 @@ * @author Alexander Merz <alexander.merz@web.de> * @copyright 2003-2005 The PHP Group * @license BSD License http://www.opensource.org/licenses/bsd-license.php - * @version CVS: $Id: IPv6.php,v 1.20 2008/11/03 18:21:01 alexmerz Exp $ + * @version CVS: $Id: IPv6.php,v 1.21 2009/05/18 01:18:19 alexmerz Exp $ * @link http://pear.php.net/package/Net_IPv6 */ @@ -242,7 +242,7 @@ * @access public * @static */ - function isInNetmask($ip, $netmask, $bits=null) + function isInNetmask($ip, $netmask, $bits=null) { // try to get the bit count @@ -406,7 +406,7 @@ * @see Compress() * @static */ - function uncompress($ip) + function uncompress($ip) { $prefix = Net_IPv6::getPrefixLength($ip); @@ -529,6 +529,13 @@ */ function compress($ip) { + + if(false !== strpos($ip, '::')) { // its already compressed + + return $ip; + + } + $prefix = Net_IPv6::getPrefixLength($ip); if (false === $prefix) { @@ -545,51 +552,45 @@ $netmask = Net_IPv6::getNetmaskSpec($ip); $ip = Net_IPv6::removeNetmaskSpec($ip); - if (!strstr($ip, '::')) { + $ipp = explode(':', $ip); - $ipp = explode(':', $ip); + for ($i = 0; $i < count($ipp); $i++) { - for ($i = 0; $i < count($ipp); $i++) { + $ipp[$i] = dechex(hexdec($ipp[$i])); - $ipp[$i] = dechex(hexdec($ipp[$i])); - - } + } - $cip = ':' . join(':', $ipp) . ':'; + $cip = ':' . join(':', $ipp) . ':'; - preg_match_all("/(:0)+/", $cip, $zeros); + preg_match_all("/(:0)+/", $cip, $zeros); - if (count($zeros[0]) > 0) { + if (count($zeros[0]) > 0) { - $match = ''; + $match = ''; - foreach ($zeros[0] as $zero) { + foreach ($zeros[0] as $zero) { - if (strlen($zero) > strlen($match)) { + if (strlen($zero) > strlen($match)) { - $match = $zero; + $match = $zero; - } } - - $cip = preg_replace('/' . $match . '/', ':', $cip, 1); - } - $cip = preg_replace('/((^:)|(:$))/', '', $cip); - $cip = preg_replace('/((^:)|(:$))/', '::', $cip); + $cip = preg_replace('/' . $match . '/', ':', $cip, 1); - if ('' != $netmask) { + } - $cip = $cip.'/'.$netmask; + $cip = preg_replace('/((^:)|(:$))/', '', $cip); + $cip = preg_replace('/((^:)|(:$))/', '::', $cip); - } + if ('' != $netmask) { - return $cip.$prefix; + $cip = $cip.'/'.$netmask; } - return $ip.$prefix; + return $cip.$prefix; } @@ -666,6 +667,12 @@ for ($i = 0; $i < count($ipv6); $i++) { + if(4 < strlen($ipv6[$i])) { + + return false; + + } + $dec = hexdec($ipv6[$i]); $hex = strtoupper(preg_replace("/^[0]{1,3}(.*[0-9a-fA-F])$/", "\\1", @@ -891,7 +898,7 @@ if (strlen($bin) < 128) { - $bin = str_pad($str, 128, '0', STR_PAD_LEFT); + $bin = str_pad($bin, 128, '0', STR_PAD_LEFT); } http://cvs.php.net/viewvc.cgi/pear/Net_IPv6/tests/NetIPv6Test.php?r1=1.8&r2=1.9&diff_format=u Index: pear/Net_IPv6/tests/NetIPv6Test.php diff -u pear/Net_IPv6/tests/NetIPv6Test.php:1.8 pear/Net_IPv6/tests/NetIPv6Test.php:1.9 --- pear/Net_IPv6/tests/NetIPv6Test.php:1.8 Sun Dec 28 01:07:19 2008 +++ pear/Net_IPv6/tests/NetIPv6Test.php Mon May 18 01:18:20 2009 @@ -16,7 +16,7 @@ // | Authors: Alexander Merz <alexander.merz@web.de> | // +----------------------------------------------------------------------+ // -// $Id: NetIPv6Test.php,v 1.8 2008/12/28 01:07:19 clockwerx Exp $ +// $Id: NetIPv6Test.php,v 1.9 2009/05/18 01:18:20 alexmerz Exp $ require_once "Net/IPv6.php"; require_once "PHPUnit/Framework/TestCase.php"; @@ -26,7 +26,7 @@ * * @author Alexander Merz <alexander.merz@t-online.de> * @package Net_IPv6 -* @version $Id: NetIPv6Test.php,v 1.8 2008/12/28 01:07:19 clockwerx Exp $ +* @version $Id: NetIPv6Test.php,v 1.9 2009/05/18 01:18:20 alexmerz Exp $ * @access public */ class NetIPv6Test extends PHPUnit_Framework_TestCase { @@ -211,16 +211,18 @@ } /** - * Should handle compr + * this testcase handles Bug 14747 + * which covers already compressed adresses + * to keep as is */ - public function testFoo() { + public function testBug14747_CompressShouldDoNothingOnCompressedIPs() { + $testip = '2001:503:ba3e::2:30'; $is = Net_IPv6::compress($testip); - $this->assertEquals("2001:503:ba3e:0:0:0:2:30", $is); - + $this->assertEquals("2001:503:ba3e::2:30", $is); - $testip = 'ff01:0:0:0:0:0:0:101'; + $testip = 'ff01::101'; $is = Net_IPv6::compress($testip); $this->assertEquals("ff01::101", $is); @@ -267,6 +269,20 @@ } /** + * handle Bug 15947 + * checkIpv6 returns true although IP is too long + */ + public function testBug15947_IpTooLong() { + + $testIp = '2001:0ec8:0000:0000:0000:0000:0000:0001111'; + + $is = Net_IPv6::checkIPv6($testIp); + + $this->assertFalse($is); + + } + + /** * this testcase handles compress * */
« previous php.pear.cvs (#56110) next »