Permalink
Browse files

Adding tilde (~) to accepted characters for URL validation. Fixes #52,…

… and legacy trac enhancement 6213.
  • Loading branch information...
jperras committed Sep 19, 2009
1 parent d5376e6 commit ca632461f1bf1e922b4687692ced473bec1989b5
Showing with 2 additions and 1 deletion.
  1. +1 −1 cake/libs/validation.php
  2. +1 −0 cake/tests/cases/libs/validation.test.php
View
@@ -843,7 +843,7 @@ function ssn($check, $regex = null, $country = null) {
function url($check, $strict = false) {
$_this =& Validation::getInstance();
$_this->check = $check;
- $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=') . '\/0-9a-z]|(%[0-9a-f]{2}))';
+ $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z]|(%[0-9a-f]{2}))';
$_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
'(?:' . $_this->__pattern['ip'] . '|' . $_this->__pattern['hostname'] . ')(?::[1-9][0-9]{0,3})?' .
'(?:\/?|\/' . $validChars . '*)?' .
@@ -1755,6 +1755,7 @@ function testUrl() {
$this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
$this->assertFalse(Validation::url('www.cakephp.org', true));
$this->assertTrue(Validation::url('http://www.cakephp.org', true));
+ $this->assertTrue(Validation::url('http://example.com/~userdir/'));
}
/**

0 comments on commit ca63246

Please sign in to comment.