Fixing validation of URLs with round brackets. Patch from 'dho' added.

Closes #5685

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7826 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-11-05 03:49:55 +00:00
parent 7822a69b7f
commit ea30a48c5a
2 changed files with 7 additions and 5 deletions

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* Validation Class. Used for validation of model data
*
* Long description for file
*
@ -836,7 +836,7 @@ class Validation extends Object {
$_this->check = $check;
$_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\\/\\/)?(?:(?:(?:25[0-5]|2[0-4]\d|(?:(?:1\d)?|[1-9]?)\d)\.){3}(?:25[0-5]|2[0-4]\d|(?:(?:1\d)?|[1-9]?)\d)'
. '|(?:[0-9a-z]{1}[0-9a-z\\-]*\\.)*(?:[0-9a-z]{1}[0-9a-z\\-]{0,62})\\.(?:[a-z]{2,6}|[a-z]{2}\\.[a-z]{2,6})'
. '(?::[0-9]{1,4})?)(?:\\/?|\\/[\\w\\-\\.,\'@?^=%&:;\/~\\+#]*[\\w\\-\\@?^=%&\/~\\+#])$/i';
. '(?::[0-9]{1,4})?)(?:\\/?|\\/[\\w\\-\\.,\'@?^=%&:;\/~\\+\(\)#]*[\\w\\-\\@?^=%&\/~\\+\(\)#])$/i';
return $_this->_check();
}
/**

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* Validation Class Test Case
*
* Long description for file
*
@ -45,7 +45,7 @@ class CustomValidator {
}
/**
* Short description for class.
* Test Case for Validation Class
*
* @package cake.tests
* @subpackage cake.tests.cases.libs
@ -1644,6 +1644,8 @@ class ValidationTestCase extends CakeTestCase {
$this->assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com'));
$this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com'));
$this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2'));
$this->assertTrue(Validation::url('http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)'));
$this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
}
/**
* testInList method