Browse Source

Exclude domain names starting with `-`

Related to 479aefc438a071d5c7d9e2724f77d8740d57ee77

Refs #3414
mark_story 13 years ago
parent
commit
2b0e10eebb
2 changed files with 5 additions and 5 deletions
  1. 1 0
      lib/Cake/Test/Case/Utility/ValidationTest.php
  2. 4 5
      lib/Cake/Utility/Validation.php

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

@@ -1856,6 +1856,7 @@ class ValidationTest extends CakeTestCase {
 		$this->assertFalse(Validation::url('http://_jabber._tcp.g_mail.com'));
 		$this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
 		$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->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html'));

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

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