diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 3b398d0d5..17b436239 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -928,6 +928,9 @@ class HashTest extends CakeTestCase { * @return void */ public function testSort() { + $result = Hash::sort(array(), '{n}.name', 'asc'); + $this->assertEquals(array(), $result); + $a = array( 0 => array( 'Person' => array('name' => 'Jeff'), diff --git a/lib/Cake/Test/Case/Utility/SetTest.php b/lib/Cake/Test/Case/Utility/SetTest.php index 4ee3a85f5..1bd20aae4 100644 --- a/lib/Cake/Test/Case/Utility/SetTest.php +++ b/lib/Cake/Test/Case/Utility/SetTest.php @@ -225,6 +225,9 @@ class SetTest extends CakeTestCase { * @return void */ public function testSort() { + $result = Set::sort(array(), '{n}.name', 'asc'); + $this->assertEquals(array(), $result); + $a = array( 0 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), 1 => array('Person' => array('name' => 'Tracy'),'Friend' => array(array('name' => 'Lindsay'))) diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 56f935a1b..6b625e92f 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -1655,6 +1655,11 @@ class ValidationTest extends CakeTestCase { $this->assertTrue(Validation::email('abc@example.travel')); $this->assertTrue(Validation::email('someone@st.t-com.hr')); + // gTLD's + $this->assertTrue(Validation::email('example@host.local')); + $this->assertTrue(Validation::email('example@x.org')); + $this->assertTrue(Validation::email('example@host.xxx')); + // strange, but technically valid email addresses $this->assertTrue(Validation::email('S=postmaster/OU=rz/P=uni-frankfurt/A=d400/C=de@gateway.d400.de')); $this->assertTrue(Validation::email('customer/department=shipping@example.com')); @@ -1669,7 +1674,6 @@ class ValidationTest extends CakeTestCase { $this->assertFalse(Validation::email('abc.@example.com')); $this->assertFalse(Validation::email('abc@example..com')); $this->assertFalse(Validation::email('abc@example.com.a')); - $this->assertFalse(Validation::email('abc@example.toolong')); $this->assertFalse(Validation::email('abc;@example.com')); $this->assertFalse(Validation::email('abc@example.com;')); $this->assertFalse(Validation::email('abc@efg@example.com')); @@ -1839,11 +1843,11 @@ class ValidationTest extends CakeTestCase { $this->assertTrue(Validation::url('http://example.com/~userdir/')); $this->assertTrue(Validation::url('http://underscore_subdomain.example.org')); $this->assertTrue(Validation::url('http://_jabber._tcp.gmail.com')); + $this->assertTrue(Validation::url('http://www.domain.longttldnotallowed')); $this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake')); $this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake')); $this->assertFalse(Validation::url('http://w_w.domain.co_m')); $this->assertFalse(Validation::url('http://www.domain.12com')); - $this->assertFalse(Validation::url('http://www.domain.longttldnotallowed')); $this->assertFalse(Validation::url('http://www.-invaliddomain.tld')); $this->assertFalse(Validation::url('http://www.domain.-invalidtld')); $this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com')); diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index 5b8308f88..023357692 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -732,6 +732,9 @@ class Hash { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::sort */ public static function sort(array $data, $path, $dir, $type = 'regular') { + if (empty($data)) { + return array(); + } $originalKeys = array_keys($data); $numeric = is_numeric(implode('', $originalKeys)); if ($numeric) { diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 72eba937d..a80a8fa03 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -956,6 +956,9 @@ class Set { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::sort */ public static function sort($data, $path, $dir) { + if (empty($data)) { + return $data; + } $originalKeys = array_keys($data); $numeric = false; if (is_numeric(implode('', $originalKeys))) { diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index a8f0d225a..e1387389a 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -39,7 +39,7 @@ class Validation { * @var array */ protected static $_pattern = array( - 'hostname' => '(?:[-_a-z0-9][-_a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)' + 'hostname' => '(?:[-_a-z0-9][-_a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,})' ); /**