mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Update TLD validation to accept gTLD variations
The upcoming gTLD extensions will allow much more variety in TLD names. Loosen the validation to better accept different length TLDs. Fixes #3414
This commit is contained in:
parent
889c1ebc09
commit
479aefc438
2 changed files with 7 additions and 3 deletions
|
@ -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'));
|
||||
|
|
|
@ -38,7 +38,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,})'
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue