Merge branch '2.1' into 2.2

This commit is contained in:
mark_story 2012-06-10 20:34:20 -04:00
commit 76dd49145a
2 changed files with 6 additions and 6 deletions

View file

@ -1657,7 +1657,7 @@ class ValidationTest extends CakeTestCase {
* @return void
*/
public function testIpV4() {
$this->assertTrue(Validation::ip('0.0.0.0'));
$this->assertTrue(Validation::ip('0.0.0.0', 'ipv4'));
$this->assertTrue(Validation::ip('192.168.1.156'));
$this->assertTrue(Validation::ip('255.255.255.255'));
$this->assertFalse(Validation::ip('127.0.0'));

View file

@ -468,12 +468,12 @@ class Validation {
*/
public static function ip($check, $type = 'both') {
$type = strtolower($type);
$flags = null;
if ($type === 'ipv4' || $type === 'both') {
$flags |= FILTER_FLAG_IPV4;
$flags = 0;
if ($type === 'ipv4') {
$flags = FILTER_FLAG_IPV4;
}
if ($type === 'ipv6' || $type === 'both') {
$flags |= FILTER_FLAG_IPV6;
if ($type === 'ipv6') {
$flags = FILTER_FLAG_IPV6;
}
return (boolean)filter_var($check, FILTER_VALIDATE_IP, array('flags' => $flags));
}