Exclude domain names starting with -

Related to 479aefc438

Refs #3414
This commit is contained in:
mark_story 2013-04-29 21:31:30 -04:00
parent ac94d11e65
commit 2b0e10eebb
2 changed files with 5 additions and 5 deletions

View file

@ -1856,6 +1856,7 @@ class ValidationTest extends CakeTestCase {
$this->assertFalse(Validation::url('http://_jabber._tcp.g_mail.com')); $this->assertFalse(Validation::url('http://_jabber._tcp.g_mail.com'));
$this->assertFalse(Validation::url('http://en.(wikipedia).org/')); $this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
$this->assertFalse(Validation::url('http://www.domain.com/fakeenco%ode')); $this->assertFalse(Validation::url('http://www.domain.com/fakeenco%ode'));
$this->assertFalse(Validation::url('--.example.com'));
$this->assertFalse(Validation::url('www.cakephp.org', true)); $this->assertFalse(Validation::url('www.cakephp.org', true));
$this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html')); $this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html'));

View file

@ -1,7 +1,5 @@
<?php <?php
/** /**
* Validation Class. Used for validation of model data
*
* PHP Version 5.x * PHP Version 5.x
* *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
@ -13,7 +11,6 @@
* *
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project * @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Utility
* @since CakePHP(tm) v 1.2.0.3830 * @since CakePHP(tm) v 1.2.0.3830
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
@ -21,16 +18,18 @@
App::uses('Multibyte', 'I18n'); App::uses('Multibyte', 'I18n');
App::uses('File', 'Utility'); App::uses('File', 'Utility');
App::uses('CakeNumber', 'Utility'); App::uses('CakeNumber', 'Utility');
// Load multibyte if the extension is missing. // Load multibyte if the extension is missing.
if (!function_exists('mb_strlen')) { if (!function_exists('mb_strlen')) {
class_exists('Multibyte'); class_exists('Multibyte');
} }
/** /**
* Validation Class. Used for validation of model data
*
* Offers different validation methods. * Offers different validation methods.
* *
* @package Cake.Utility * @package Cake.Utility
* @since CakePHP v 1.2.0.3830
*/ */
class Validation { class Validation {
@ -40,7 +39,7 @@ class Validation {
* @var array * @var array
*/ */
protected static $_pattern = 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,})' 'hostname' => '(?:[_a-z0-9][-_a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,})'
); );
/** /**