Browse Source

Merge branch '2.1' into 2.2

mark_story 14 years ago
parent
commit
76dd49145a
2 changed files with 6 additions and 6 deletions
  1. 1 1
      lib/Cake/Test/Case/Utility/ValidationTest.php
  2. 5 5
      lib/Cake/Utility/Validation.php

+ 1 - 1
lib/Cake/Test/Case/Utility/ValidationTest.php

@@ -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'));

+ 5 - 5
lib/Cake/Utility/Validation.php

@@ -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));
 	}